List Info

Thread: cherrypy.request.headers - why haven't I got any ?




cherrypy.request.headers - why haven't I got any ?
user name
2006-11-03 04:56:35
I'm trying to get access to the 'Referer' header value when
a page is
requested but I cannot !

I'm running CP 2.1.1 with Apache in front of it. Everything
works
normally apart from this. At first I thought the headers
structure was
dictionary (as per http:/
/docs.cherrypy.org/api-reference#request) but
I got error messages suggesting it was a generator (I don't
know much
about generators) so I tried doing this eventually to dump
them all out
and I get no output.

try:
  print "About to iterate headers"
  while 1:
    print cherrypy.request.headers.next()
except StopIteration:
  pass
print "About to iterate headers - again"
for k in cherrypy.request.headers():
  print k


Could anyone tell me how they go about accessing something
out of this
structure (and bearing in mind I'm using an old version of
CP ?).

thanks

Richard.


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en

-~----------~----~----~----~------~----~------~--~---

cherrypy.request.headers - why haven't I got any ?
user name
2006-11-03 14:11:40
Try cherrypy.request.headerMap. ; I think that in 2.1, cherrypy.request.headers was a tuple or a list of (header_name, value) pairs.  Not sure why you can't see those though...

Christian
http://www.dowski.com

On 11/2/06, northof40 < shearichardgmail.com">shearichardgmail.com > wrote:

I'm trying to get access to the 'Referer' header value when a page is
requested but I cannot !

I'm running CP 2.1.1 with Apache in front of it. Everything works
normally apart from this. At first I thought the headers structure was
dictionary (as per http://docs.cherrypy.org/api-reference#request) but
I got error messages suggesting it was a generator (I don't know much
about generators) so I tried doing this eventually to dump them all out
and I get no output.

try:
  print "About to iterate headers&quot;
 &nbsp;while 1:
 &nbsp;  print cherrypy.request.headers.next()
except StopIteration:
  pass
print "About to iterate headers - again";
for k in cherrypy.request.headers():
&nbsp; print k


Could anyone tell me how they go about accessing something out of this
structure (and bearing in mind I'm using an old version of CP ?).

thanks

Richard.



--~--~---------~--~----~------------~-------~--~----~
 ;You received this message because you are subscribed to the Google Groups "cherrypy-users&quot; group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )