changeset 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 9451a941c536
files mercurial/httprepo.py mercurial/keepalive.py
diffstat 2 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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]
--- 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