diff options
author | Ben Murdoch <benm@google.com> | 2010-05-11 18:35:50 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-05-14 10:23:05 +0100 |
commit | 21939df44de1705786c545cd1bf519d47250322d (patch) | |
tree | ef56c310f5c0cdc379c2abb2e212308a3281ce20 /WebKitTools/Scripts/webkitpy/thirdparty/autoinstalled/mechanize/_upgrade.py | |
parent | 4ff1d8891d520763f17675827154340c7c740f90 (diff) | |
download | external_webkit-21939df44de1705786c545cd1bf519d47250322d.zip external_webkit-21939df44de1705786c545cd1bf519d47250322d.tar.gz external_webkit-21939df44de1705786c545cd1bf519d47250322d.tar.bz2 |
Merge Webkit at r58956: Initial merge by Git.
Change-Id: I1d9fb60ea2c3f2ddc04c17a871acdb39353be228
Diffstat (limited to 'WebKitTools/Scripts/webkitpy/thirdparty/autoinstalled/mechanize/_upgrade.py')
-rw-r--r-- | WebKitTools/Scripts/webkitpy/thirdparty/autoinstalled/mechanize/_upgrade.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/WebKitTools/Scripts/webkitpy/thirdparty/autoinstalled/mechanize/_upgrade.py b/WebKitTools/Scripts/webkitpy/thirdparty/autoinstalled/mechanize/_upgrade.py new file mode 100644 index 0000000..df59c01 --- /dev/null +++ b/WebKitTools/Scripts/webkitpy/thirdparty/autoinstalled/mechanize/_upgrade.py @@ -0,0 +1,40 @@ +from urllib2 import BaseHandler + +from _request import Request +from _response import upgrade_response +from _util import deprecation + + +class HTTPRequestUpgradeProcessor(BaseHandler): + # upgrade urllib2.Request to this module's Request + # yuck! + handler_order = 0 # before anything else + + def http_request(self, request): + if not hasattr(request, "add_unredirected_header"): + newrequest = Request(request.get_full_url(), request.data, + request.headers) + try: newrequest.origin_req_host = request.origin_req_host + except AttributeError: pass + try: newrequest.unverifiable = request.unverifiable + except AttributeError: pass + try: newrequest.visit = request.visit + except AttributeError: pass + request = newrequest + return request + + https_request = http_request + + +class ResponseUpgradeProcessor(BaseHandler): + # upgrade responses to be .close()able without becoming unusable + handler_order = 0 # before anything else + + def __init__(self): + deprecation( + "See http://wwwsearch.sourceforge.net/mechanize/doc.html#seekable") + + def any_response(self, request, response): + if not hasattr(response, 'closeable_response'): + response = upgrade_response(response) + return response |