source: py-scraping/mechanize/_debug.py@ 215

Last change on this file since 215 was 106, checked in by Rick van der Zwet, 15 years ago

Initial commit...

File size: 932 bytes
RevLine 
[106]1import logging
2
3from urllib2 import BaseHandler
4from _response import response_seek_wrapper
5
6
7class HTTPResponseDebugProcessor(BaseHandler):
8 handler_order = 900 # before redirections, after everything else
9
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
20
21 https_response = http_response
22
23class 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
Note: See TracBrowser for help on using the repository browser.