En Wed, 22 Jul 2009 18:18:37 -0300, scriptlear...@gmail.com
<scriptlear...@gmail.com> escribió:
On Jul 22, 1:54 pm, "Diez B. Roggisch" <de...@nospam.web.de> wrote:
You can use proxy-tools such as tcpmon or sniff traffic using wireshark.
Thanks,
but I am trying to enable some debug mode to log all outgoing and
incoming messages for certain period of time, and running another
proxy-tool is not very ideal. It would be great to log it in some log
file.
You may install a custom HTTPHandler:
class LoggingHTTPConnection(httplib.HTTPConnection):
def request(self, method, url, body=None, headers={}):
print method, url, headers
httplib.HTTPConnection.request(self, method, url, body, headers)
def getresponse(self):
response = httplib.HTTPConnection.getresponse(self)
print response.status, response.msg
return response
class LoggingHTTPHandler(urllib2.HTTPHandler):
def http_open(self, req):
return self.do_open(LoggingHTTPConnection, req)
opener = urllib2.build_opener(LoggingHTTPHandler, ...)
--
Gabriel Genellina
--
http://mail.python.org/mailman/listinfo/python-list