# HG changeset patch # User Alexis S. L. Carvalho # Date 1202079826 7200 # Node ID 6f1fcbc58efa82cc96fcd1f3df97e9c4f1c8cd95 # Parent b6bd4ee6ed85628b26d6cd7186b76624f40548bf 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. diff -r b6bd4ee6ed85 -r 6f1fcbc58efa mercurial/httprepo.py --- a/mercurial/httprepo.py Sun Feb 03 21:03:46 2008 -0200 +++ b/mercurial/httprepo.py Sun Feb 03 21:03:46 2008 -0200 @@ -103,7 +103,7 @@ # must be able to send big bundle as stream. send = _gen_sendfile(keepalive.HTTPConnection) -class basehttphandler(keepalive.HTTPHandler): +class httphandler(keepalive.HTTPHandler): def http_open(self, req): return self.do_open(httpconnection, req) @@ -117,12 +117,9 @@ # must be able to send big bundle as stream. send = _gen_sendfile(httplib.HTTPSConnection) - class httphandler(basehttphandler, urllib2.HTTPSHandler): + class httpshandler(keepalive.KeepAliveHandler, urllib2.HTTPSHandler): def https_open(self, req): return self.do_open(httpsconnection, req) -else: - class httphandler(basehttphandler): - pass # In python < 2.5 AbstractDigestAuthHandler raises a ValueError if # it doesn't know about the auth type requested. This can happen if @@ -207,6 +204,8 @@ proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy') # XXX proxyauthinfo = None handlers = [httphandler()] + if has_https: + handlers.append(httpshandler()) if proxyurl: # proxy can be proper url or host[:port] diff -r b6bd4ee6ed85 -r 6f1fcbc58efa mercurial/keepalive.py --- a/mercurial/keepalive.py Sun Feb 03 21:03:46 2008 -0200 +++ b/mercurial/keepalive.py Sun Feb 03 21:03:46 2008 -0200 @@ -175,7 +175,7 @@ else: return dict(self._hostmap) -class HTTPHandler(urllib2.HTTPHandler): +class KeepAliveHandler: def __init__(self): self._cm = ConnectionManager() @@ -314,6 +314,9 @@ except socket.error, err: # XXX what error? raise urllib2.URLError(err) +class HTTPHandler(KeepAliveHandler, urllib2.HTTPHandler): + pass + class HTTPResponse(httplib.HTTPResponse): # we need to subclass HTTPResponse in order to # 1) add readline() and readlines() methods