diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2009-07-26 12:39:47 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2009-07-26 12:39:47 (GMT) |
commit | 0ac1f83079ee90f56bc7eef92643980a911bd355 (patch) | |
tree | 2ce2674de89d07f83132467448a9af38c0f4d29d /Lib/urllib | |
parent | 36613e08c3bec90e975eef9bdd3c9f2082a68616 (diff) | |
download | cpython-0ac1f83079ee90f56bc7eef92643980a911bd355.zip cpython-0ac1f83079ee90f56bc7eef92643980a911bd355.tar.gz cpython-0ac1f83079ee90f56bc7eef92643980a911bd355.tar.bz2 |
Backport the changes made in revision 74198, fixing the issue 1424152
Diffstat (limited to 'Lib/urllib')
-rw-r--r-- | Lib/urllib/request.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index b133fe4..f787407 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -163,6 +163,7 @@ class Request: self.full_url = unwrap(url) self.data = data self.headers = {} + self._tunnel_host = None for key, value in headers.items(): self.add_header(key, value) self.unredirected_hdrs = {} @@ -218,8 +219,12 @@ class Request: # End deprecated methods def set_proxy(self, host, type): - self.host, self.type = host, type - self.selector = self.full_url + if self.type == 'https' and not self._tunnel_host: + self._tunnel_host = self.host + else: + self.type= type + self.selector = self.full_url + self.host = host def has_proxy(self): return self.selector == self.full_url @@ -659,7 +664,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: @@ -1041,6 +1046,10 @@ class AbstractHTTPHandler(BaseHandler): # request. 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.selector, req.data, headers) r = h.getresponse() # an HTTPResponse instance |