mercurial/httprepo.py
changeset 6001 30d2fecaab76
parent 5930 c301f15c965a
parent 5983 6f1fcbc58efa
child 6211 f89fd07fc51d
--- a/mercurial/httprepo.py	Sat Feb 02 21:01:43 2008 +0100
+++ b/mercurial/httprepo.py	Sun Feb 03 21:47:07 2008 -0200
@@ -103,10 +103,13 @@
     # 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)
 
+    def __del__(self):
+        self.close_all()
+
 has_https = hasattr(urllib2, 'HTTPSHandler')
 if has_https:
     class httpsconnection(httplib.HTTPSConnection):
@@ -114,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
@@ -203,8 +203,9 @@
 
         proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy')
         # XXX proxyauthinfo = None
-        self.handler = httphandler()
-        handlers = [self.handler]
+        handlers = [httphandler()]
+        if has_https:
+            handlers.append(httpshandler())
 
         if proxyurl:
             # proxy can be proper url or host[:port]
@@ -270,11 +271,6 @@
         opener.addheaders = [('User-agent', 'mercurial/proto-1.0')]
         urllib2.install_opener(opener)
 
-    def __del__(self):
-        if self.handler:
-            self.handler.close_all()
-            self.handler = None
-
     def url(self):
         return self.path