##// END OF EJS Templates
HTTPS: fix python2.3, persistent connections, don't explode if SSL is not available...
Alexis S. L. Carvalho -
r2569:52ce0d6b default
parent child Browse files
Show More
@@ -87,25 +87,31 b' class httpconnection(keepalive.HTTPConne'
87 for chunk in util.filechunkiter(data):
87 for chunk in util.filechunkiter(data):
88 keepalive.HTTPConnection.send(self, chunk)
88 keepalive.HTTPConnection.send(self, chunk)
89
89
90 class httphandler(keepalive.HTTPHandler):
90 class basehttphandler(keepalive.HTTPHandler):
91 def http_open(self, req):
91 def http_open(self, req):
92 return self.do_open(httpconnection, req)
92 return self.do_open(httpconnection, req)
93
93
94 class httpsconnection(httplib.HTTPSConnection):
94 has_https = hasattr(urllib2, 'HTTPSHandler')
95 # must be able to send big bundle as stream.
95 if has_https:
96 class httpsconnection(httplib.HTTPSConnection):
97 response_class = keepalive.HTTPResponse
98 # must be able to send big bundle as stream.
96
99
97 def send(self, data):
100 def send(self, data):
98 if isinstance(data, str):
101 if isinstance(data, str):
99 httplib.HTTPSConnection.send(self, data)
102 httplib.HTTPSConnection.send(self, data)
100 else:
103 else:
101 # if auth required, some data sent twice, so rewind here
104 # if auth required, some data sent twice, so rewind here
102 data.seek(0)
105 data.seek(0)
103 for chunk in util.filechunkiter(data):
106 for chunk in util.filechunkiter(data):
104 httplib.HTTPSConnection.send(self, chunk)
107 httplib.HTTPSConnection.send(self, chunk)
105
108
106 class httpshandler(urllib2.HTTPSHandler):
109 class httphandler(basehttphandler, urllib2.HTTPSHandler):
107 def https_open(self, req):
110 def https_open(self, req):
108 return self.do_open(httpsconnection, req)
111 return self.do_open(httpsconnection, req)
112 else:
113 class httphandler(basehttphandler):
114 pass
109
115
110 class httprepository(remoterepository):
116 class httprepository(remoterepository):
111 def __init__(self, ui, path):
117 def __init__(self, ui, path):
@@ -176,7 +182,6 b' class httprepository(remoterepository):'
176
182
177 opener = urllib2.build_opener(
183 opener = urllib2.build_opener(
178 handler,
184 handler,
179 httpshandler(),
180 urllib2.HTTPBasicAuthHandler(passmgr),
185 urllib2.HTTPBasicAuthHandler(passmgr),
181 urllib2.HTTPDigestAuthHandler(passmgr))
186 urllib2.HTTPDigestAuthHandler(passmgr))
182
187
@@ -322,4 +327,8 b' class httprepository(remoterepository):'
322 os.unlink(tempname)
327 os.unlink(tempname)
323
328
324 class httpsrepository(httprepository):
329 class httpsrepository(httprepository):
325 pass
330 def __init__(self, ui, path):
331 if not has_https:
332 raise util.Abort(_('Python support for SSL and HTTPS '
333 'is not installed'))
334 httprepository.__init__(self, ui, path)
General Comments 0
You need to be logged in to leave comments. Login now