comparison mercurial/httprepo.py @ 5983:6f1fcbc58efa

httprepo: use separate handlers for HTTP and HTTPS This is needed to keep the code in keepalive.py from sharing the same connection between HTTP and HTTPS. 52ce0d6bc375 explains why we were using a single handler. This should fix issue892.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sun, 03 Feb 2008 21:03:46 -0200
parents b6bd4ee6ed85
children 30d2fecaab76
comparison
equal deleted inserted replaced
5982:b6bd4ee6ed85 5983:6f1fcbc58efa
101 101
102 class httpconnection(keepalive.HTTPConnection): 102 class httpconnection(keepalive.HTTPConnection):
103 # must be able to send big bundle as stream. 103 # must be able to send big bundle as stream.
104 send = _gen_sendfile(keepalive.HTTPConnection) 104 send = _gen_sendfile(keepalive.HTTPConnection)
105 105
106 class basehttphandler(keepalive.HTTPHandler): 106 class httphandler(keepalive.HTTPHandler):
107 def http_open(self, req): 107 def http_open(self, req):
108 return self.do_open(httpconnection, req) 108 return self.do_open(httpconnection, req)
109 109
110 def __del__(self): 110 def __del__(self):
111 self.close_all() 111 self.close_all()
115 class httpsconnection(httplib.HTTPSConnection): 115 class httpsconnection(httplib.HTTPSConnection):
116 response_class = keepalive.HTTPResponse 116 response_class = keepalive.HTTPResponse
117 # must be able to send big bundle as stream. 117 # must be able to send big bundle as stream.
118 send = _gen_sendfile(httplib.HTTPSConnection) 118 send = _gen_sendfile(httplib.HTTPSConnection)
119 119
120 class httphandler(basehttphandler, urllib2.HTTPSHandler): 120 class httpshandler(keepalive.KeepAliveHandler, urllib2.HTTPSHandler):
121 def https_open(self, req): 121 def https_open(self, req):
122 return self.do_open(httpsconnection, req) 122 return self.do_open(httpsconnection, req)
123 else:
124 class httphandler(basehttphandler):
125 pass
126 123
127 # In python < 2.5 AbstractDigestAuthHandler raises a ValueError if 124 # In python < 2.5 AbstractDigestAuthHandler raises a ValueError if
128 # it doesn't know about the auth type requested. This can happen if 125 # it doesn't know about the auth type requested. This can happen if
129 # somebody is using BasicAuth and types a bad password. 126 # somebody is using BasicAuth and types a bad password.
130 class httpdigestauthhandler(urllib2.HTTPDigestAuthHandler): 127 class httpdigestauthhandler(urllib2.HTTPDigestAuthHandler):
205 self.ui.debug(_('using %s\n') % self._url) 202 self.ui.debug(_('using %s\n') % self._url)
206 203
207 proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy') 204 proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy')
208 # XXX proxyauthinfo = None 205 # XXX proxyauthinfo = None
209 handlers = [httphandler()] 206 handlers = [httphandler()]
207 if has_https:
208 handlers.append(httpshandler())
210 209
211 if proxyurl: 210 if proxyurl:
212 # proxy can be proper url or host[:port] 211 # proxy can be proper url or host[:port]
213 if not (proxyurl.startswith('http:') or 212 if not (proxyurl.startswith('http:') or
214 proxyurl.startswith('https:')): 213 proxyurl.startswith('https:')):