Backporting the changes made in revision 72880 as fix for Issue1424152.

This commit is contained in:
Senthil Kumaran 2009-07-26 12:36:08 +00:00
parent 47ccf0cbba
commit 308681c405
4 changed files with 60 additions and 3 deletions

View file

@ -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()