| 1 |
from __future__ import absolute_import |
| 2 |
|
| 3 |
import logging |
| 4 |
|
| 5 |
from ._response import response_seek_wrapper |
| 6 |
from ._urllib2_fork import BaseHandler |
| 7 |
|
| 8 |
|
| 9 |
class HTTPResponseDebugProcessor(BaseHandler): |
| 10 |
handler_order = 900 |
| 11 |
|
| 12 |
def http_response(self, request, response): |
| 13 |
if not hasattr(response, "seek"): |
| 14 |
response = response_seek_wrapper(response) |
| 15 |
info = logging.getLogger("mechanize.http_responses").info |
| 16 |
try: |
| 17 |
info(response.read()) |
| 18 |
finally: |
| 19 |
response.seek(0) |
| 20 |
info("*****************************************************") |
| 21 |
return response |
| 22 |
|
| 23 |
https_response = http_response |
| 24 |
|
| 25 |
|
| 26 |
class HTTPRedirectDebugProcessor(BaseHandler): |
| 27 |
|
| 28 |
def http_request(self, request): |
| 29 |
if hasattr(request, "redirect_dict"): |
| 30 |
info = logging.getLogger("mechanize.http_redirects").info |
| 31 |
info("redirecting to %s", request.get_full_url()) |
| 32 |
return request |
| 33 |
|
| 34 |
https_request = http_request |