Line | |
---|
1 | import logging
|
---|
2 |
|
---|
3 | from urllib2 import BaseHandler
|
---|
4 | from _response import response_seek_wrapper
|
---|
5 |
|
---|
6 |
|
---|
7 | class 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 |
|
---|
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
|
---|
Note:
See
TracBrowser
for help on using the repository browser.