comparison mercurial/httprepo.py @ 2557:1727ff712a4e

Fix push over https. Without this patch, python gives me a TypeError: write() argument 1 must be string or read-only buffer, not file
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Mon, 03 Jul 2006 00:23:58 -0300
parents f1ebc4311f47
children 52ce0d6bc375
comparison
equal deleted inserted replaced
2556:f1ebc4311f47 2557:1727ff712a4e
88 keepalive.HTTPConnection.send(self, chunk) 88 keepalive.HTTPConnection.send(self, chunk)
89 89
90 class httphandler(keepalive.HTTPHandler): 90 class httphandler(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
94 class httpsconnection(httplib.HTTPSConnection):
95 # must be able to send big bundle as stream.
96
97 def send(self, data):
98 if isinstance(data, str):
99 httplib.HTTPSConnection.send(self, data)
100 else:
101 # if auth required, some data sent twice, so rewind here
102 data.seek(0)
103 for chunk in util.filechunkiter(data):
104 httplib.HTTPSConnection.send(self, chunk)
105
106 class httpshandler(urllib2.HTTPSHandler):
107 def https_open(self, req):
108 return self.do_open(httpsconnection, req)
93 109
94 class httprepository(remoterepository): 110 class httprepository(remoterepository):
95 def __init__(self, ui, path): 111 def __init__(self, ui, path):
96 self.caps = None 112 self.caps = None
97 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) 113 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path)
158 (user, passwd and '*' * len(passwd) or 'not set')) 174 (user, passwd and '*' * len(passwd) or 'not set'))
159 passmgr.add_password(None, host, user, passwd or '') 175 passmgr.add_password(None, host, user, passwd or '')
160 176
161 opener = urllib2.build_opener( 177 opener = urllib2.build_opener(
162 handler, 178 handler,
179 httpshandler(),
163 urllib2.HTTPBasicAuthHandler(passmgr), 180 urllib2.HTTPBasicAuthHandler(passmgr),
164 urllib2.HTTPDigestAuthHandler(passmgr)) 181 urllib2.HTTPDigestAuthHandler(passmgr))
165 182
166 # 1.0 here is the _protocol_ version 183 # 1.0 here is the _protocol_ version
167 opener.addheaders = [('User-agent', 'mercurial/proto-1.0')] 184 opener.addheaders = [('User-agent', 'mercurial/proto-1.0')]