diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2009-07-26 12:36:08 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2009-07-26 12:36:08 (GMT) |
commit | 308681c405177dd893384bb039854c08c88e852c (patch) | |
tree | 8299437012b95b64095856315257dc792586b347 /Lib/urllib2.py | |
parent | 47ccf0cbbaa4797d9d32c51c70d51a711a8d5fe0 (diff) | |
download | cpython-308681c405177dd893384bb039854c08c88e852c.zip cpython-308681c405177dd893384bb039854c08c88e852c.tar.gz cpython-308681c405177dd893384bb039854c08c88e852c.tar.bz2 |
Backporting the changes made in revision 72880 as fix for Issue1424152.
Diffstat (limited to 'Lib/urllib2.py')
-rw-r--r-- | Lib/urllib2.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/Lib/urllib2.py b/Lib/urllib2.py index d36aa80..cf7e1fa 100644 --- a/Lib/urllib2.py +++ b/Lib/urllib2.py @@ -192,6 +192,7 @@ class Request: # self.__r_type is what's left after doing the splittype self.host = None self.port = None + self._tunnel_host = None self.data = data self.headers = {} for key, value in headers.items(): @@ -252,8 +253,13 @@ class Request: return self.__r_host def set_proxy(self, host, type): - self.host, self.type = host, type - self.__r_host = self.__original + if self.type == 'https' and not self._tunnel_host: + self._tunnel_host = self.host + else: + self.type = type + self.__r_host = self.__original + + self.host = host def has_proxy(self): return self.__r_host == self.__original @@ -700,7 +706,7 @@ class ProxyHandler(BaseHandler): req.add_header('Proxy-authorization', 'Basic ' + creds) hostport = unquote(hostport) req.set_proxy(hostport, proxy_type) - if orig_type == proxy_type: + if orig_type == proxy_type or orig_type == 'https': # let other handlers take care of it return None else: @@ -1098,6 +1104,10 @@ class AbstractHTTPHandler(BaseHandler): headers["Connection"] = "close" headers = dict( (name.title(), val) for name, val in headers.items()) + + if req._tunnel_host: + h._set_tunnel(req._tunnel_host) + try: h.request(req.get_method(), req.get_selector(), req.data, headers) r = h.getresponse() |