##// END OF EJS Templates
httpconnection: correctly handle redirects from http to https...
Augie Fackler -
r14346:bf85c263 default
parent child Browse files
Show More
@@ -132,7 +132,7 b' class http2handler(urllib2.HTTPHandler, '
132 132 self._connections = {}
133 133
134 134 # shamelessly borrowed from urllib2.AbstractHTTPHandler
135 def do_open(self, http_class, req):
135 def do_open(self, http_class, req, use_ssl):
136 136 """Return an addinfourl object for the request, using http_class.
137 137
138 138 http_class must implement the HTTPConnection API from httplib.
@@ -173,7 +173,8 b' class http2handler(urllib2.HTTPHandler, '
173 173 if not host:
174 174 raise urllib2.URLError('no host given')
175 175
176 allconns = self._connections.get((host, proxy), [])
176 connkey = use_ssl, host, proxy
177 allconns = self._connections.get(connkey, [])
177 178 conns = [c for c in allconns if not c.busy()]
178 179 if conns:
179 180 h = conns[0]
@@ -185,7 +186,7 b' class http2handler(urllib2.HTTPHandler, '
185 186 if req.timeout is not socket._GLOBAL_DEFAULT_TIMEOUT:
186 187 timeout = req.timeout
187 188 h = http_class(host, timeout=timeout, proxy_hostport=proxy)
188 self._connections.setdefault((host, proxy), []).append(h)
189 self._connections.setdefault(connkey, []).append(h)
189 190
190 191 headers = dict(req.headers)
191 192 headers.update(req.unredirected_hdrs)
@@ -217,7 +218,7 b' class http2handler(urllib2.HTTPHandler, '
217 218 def http_open(self, req):
218 219 if req.get_full_url().startswith('https'):
219 220 return self.https_open(req)
220 return self.do_open(HTTPConnection, req)
221 return self.do_open(HTTPConnection, req, False)
221 222
222 223 def https_open(self, req):
223 224 res = readauthforuri(self.ui, req.get_full_url())
@@ -227,7 +228,7 b' class http2handler(urllib2.HTTPHandler, '
227 228 self.ui.debug("using auth.%s.* for authentication\n" % group)
228 229 else:
229 230 self.auth = None
230 return self.do_open(self._makesslconnection, req)
231 return self.do_open(self._makesslconnection, req, True)
231 232
232 233 def _makesslconnection(self, host, port=443, *args, **kwargs):
233 234 keyfile = None
General Comments 0
You need to be logged in to leave comments. Login now