I didn't try it, but the Request Class from urllib2 has a method called, header_items(). That could be what your looking for.
On Mar 3, 1:38 am, cgoldberg <cgoldb...@gmail.com> wrote: > I have a Python web client that uses urllib2. It is easy enough to > add my own HTTP headers to the outgoing requests. I just create a > dictionary of the headers I want to add, and pass it to the Request > initializer. > > These custom headers are not all that gets sent. urllib2 attaches > headers also. You can view the headers that urrlib2 adds by looking > at unredirected_hdrs. > > However, these aren't the only HTTP headers that get sent on the > wire. Other standard HTTP headers get added to outgoing requests as > well as the custom ones I explicitly add and urllib2 adds. When I > sniff the request using Wireshark, I see headers besides the ones I > added myself. > > My question is how do a I get access to *all* of these headers? I > want to log every request (including the full set of HTTP headers that > get sent) that gets sent from my program, and can't figure out how. > any pointers? > > In a nutshell: How do I get *all* the outgoing headers from an HTTP > request created by urllib2? > > - Corey Goldberg -- http://mail.python.org/mailman/listinfo/python-list