Fullscreen support, UI fixes, reset improved
[smpy-maemo.git] / mechanize / _debug.py
blob596b11477ea1da147551f5516e04b0f7c1b303f7
1 import logging
3 from urllib2 import BaseHandler
4 from _response import response_seek_wrapper
7 class HTTPResponseDebugProcessor(BaseHandler):
8 handler_order = 900 # before redirections, after everything else
10 def http_response(self, request, response):
11 if not hasattr(response, "seek"):
12 response = response_seek_wrapper(response)
13 info = logging.getLogger("mechanize.http_responses").info
14 try:
15 info(response.read())
16 finally:
17 response.seek(0)
18 info("*****************************************************")
19 return response
21 https_response = http_response
23 class HTTPRedirectDebugProcessor(BaseHandler):
24 def http_request(self, request):
25 if hasattr(request, "redirect_dict"):
26 info = logging.getLogger("mechanize.http_redirects").info
27 info("redirecting to %s", request.get_full_url())
28 return request