# HG changeset patch # User Alexis S. L. Carvalho # Date 1162403591 10800 # Node ID 802da51cab5bf27ea898b04f01e51a8f5366372c # Parent f4c9bb4ad7b1a4b40d885d5ff46d75f76d1e3439 Use httpconnection even with proxies. This should give us HTTP keepalive when we talk to proxies and should allow us to stream a file in unbundle (instead of reading everything into a string). This should fix issue376. diff -r f4c9bb4ad7b1 -r 802da51cab5b mercurial/httprepo.py --- a/mercurial/httprepo.py Wed Nov 01 17:56:55 2006 +0100 +++ b/mercurial/httprepo.py Wed Nov 01 14:53:11 2006 -0300 @@ -132,7 +132,7 @@ proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy') # XXX proxyauthinfo = None - handler = httphandler() + handlers = [httphandler()] if proxyurl: # proxy can be proper url or host[:port] @@ -164,7 +164,7 @@ proxyscheme, netlocunsplit(proxyhost, proxyport, proxyuser, proxypasswd or ''), proxypath, proxyquery, proxyfrag)) - handler = urllib2.ProxyHandler({scheme: proxyurl}) + handlers.append(urllib2.ProxyHandler({scheme: proxyurl})) ui.debug(_('proxying through http://%s:%s\n') % (proxyhost, proxyport)) @@ -183,10 +183,9 @@ (user, passwd and '*' * len(passwd) or 'not set')) passmgr.add_password(None, host, user, passwd or '') - opener = urllib2.build_opener( - handler, - urllib2.HTTPBasicAuthHandler(passmgr), - urllib2.HTTPDigestAuthHandler(passmgr)) + handlers.extend((urllib2.HTTPBasicAuthHandler(passmgr), + urllib2.HTTPDigestAuthHandler(passmgr))) + opener = urllib2.build_opener(*handlers) # 1.0 here is the _protocol_ version opener.addheaders = [('User-agent', 'mercurial/proto-1.0')] @@ -222,11 +221,8 @@ cu = "%s%s" % (self._url, qs) try: if data: - if isinstance(data, file): - # urllib2 needs string or buffer when using a proxy - data.seek(0) - data = data.read() - self.ui.debug(_("sending %d bytes\n") % len(data)) + self.ui.debug(_("sending %s bytes\n") % + headers.get('content-length', 'X')) resp = urllib2.urlopen(urllib2.Request(cu, data, headers)) except urllib2.HTTPError, inst: if inst.code == 401: