I am trying to fetch a page with Python, and using the cookie jar.
jar = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
opener.addheaders = [('User-agent', 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)')]
response = opener.open('http://www.example.com/')
print response.info()
Using the above, I can get the response headers, but other than WireShark, can I see the request headers? What urllib2 was sending?
No, though the docs indicate that there isn’t much added. You could setup an http server in python, send the request to it first, pull out the headers, and then check those. But if you have wireshark, it’s less work to just use that.