StvOR!

March 19, 2008

Debugging Python HTTPConection recipe

Filed under: All, Linux, Python

Nice built in way to debug http connections problems in your python code.

This is nothing new, just for my reference, so I don’t have to hunt it down every time I need it.

   import httplib
   import urllib2

   # For urllib it's enough to do
   # httplib.HTTPConnection.debuglevel = 1
   #
   # but for urllib2 we have to:
   handler =  urllib2.HTTPHandler(debuglevel=1)
   opener = urllib2.build_opener(handler)
   urllib2.install_opener(opener)

Sources: python docs, Jamie Grove, python mailing list






















Get free blog up and running in minutes with Blogsome | Theme designs available here