##// END OF EJS Templates
Use httpconnection even with proxies....
Alexis S. L. Carvalho -
r3608:802da51c default
parent child Browse files
Show More
@@ -132,7 +132,7 b' class httprepository(remoterepository):'
132
132
133 proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy')
133 proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy')
134 # XXX proxyauthinfo = None
134 # XXX proxyauthinfo = None
135 handler = httphandler()
135 handlers = [httphandler()]
136
136
137 if proxyurl:
137 if proxyurl:
138 # proxy can be proper url or host[:port]
138 # proxy can be proper url or host[:port]
@@ -164,7 +164,7 b' class httprepository(remoterepository):'
164 proxyscheme, netlocunsplit(proxyhost, proxyport,
164 proxyscheme, netlocunsplit(proxyhost, proxyport,
165 proxyuser, proxypasswd or ''),
165 proxyuser, proxypasswd or ''),
166 proxypath, proxyquery, proxyfrag))
166 proxypath, proxyquery, proxyfrag))
167 handler = urllib2.ProxyHandler({scheme: proxyurl})
167 handlers.append(urllib2.ProxyHandler({scheme: proxyurl}))
168 ui.debug(_('proxying through http://%s:%s\n') %
168 ui.debug(_('proxying through http://%s:%s\n') %
169 (proxyhost, proxyport))
169 (proxyhost, proxyport))
170
170
@@ -183,10 +183,9 b' class httprepository(remoterepository):'
183 (user, passwd and '*' * len(passwd) or 'not set'))
183 (user, passwd and '*' * len(passwd) or 'not set'))
184 passmgr.add_password(None, host, user, passwd or '')
184 passmgr.add_password(None, host, user, passwd or '')
185
185
186 opener = urllib2.build_opener(
186 handlers.extend((urllib2.HTTPBasicAuthHandler(passmgr),
187 handler,
187 urllib2.HTTPDigestAuthHandler(passmgr)))
188 urllib2.HTTPBasicAuthHandler(passmgr),
188 opener = urllib2.build_opener(*handlers)
189 urllib2.HTTPDigestAuthHandler(passmgr))
190
189
191 # 1.0 here is the _protocol_ version
190 # 1.0 here is the _protocol_ version
192 opener.addheaders = [('User-agent', 'mercurial/proto-1.0')]
191 opener.addheaders = [('User-agent', 'mercurial/proto-1.0')]
@@ -222,11 +221,8 b' class httprepository(remoterepository):'
222 cu = "%s%s" % (self._url, qs)
221 cu = "%s%s" % (self._url, qs)
223 try:
222 try:
224 if data:
223 if data:
225 if isinstance(data, file):
224 self.ui.debug(_("sending %s bytes\n") %
226 # urllib2 needs string or buffer when using a proxy
225 headers.get('content-length', 'X'))
227 data.seek(0)
228 data = data.read()
229 self.ui.debug(_("sending %d bytes\n") % len(data))
230 resp = urllib2.urlopen(urllib2.Request(cu, data, headers))
226 resp = urllib2.urlopen(urllib2.Request(cu, data, headers))
231 except urllib2.HTTPError, inst:
227 except urllib2.HTTPError, inst:
232 if inst.code == 401:
228 if inst.code == 401:
General Comments 0
You need to be logged in to leave comments. Login now