##// END OF EJS Templates
url: use url.url in proxyhandler
Brodie Rao -
r13820:65b89e80 default
parent child Browse files
Show More
@@ -7,7 +7,7 b''
7 # This software may be used and distributed according to the terms of the
7 # This software may be used and distributed according to the terms of the
8 # GNU General Public License version 2 or any later version.
8 # GNU General Public License version 2 or any later version.
9
9
10 import urllib, urllib2, urlparse, httplib, os, socket, cStringIO
10 import urllib, urllib2, httplib, os, socket, cStringIO
11 import __builtin__
11 import __builtin__
12 from i18n import _
12 from i18n import _
13 import keepalive, util
13 import keepalive, util
@@ -407,14 +407,10 b' class proxyhandler(urllib2.ProxyHandler)'
407 if not (proxyurl.startswith('http:') or
407 if not (proxyurl.startswith('http:') or
408 proxyurl.startswith('https:')):
408 proxyurl.startswith('https:')):
409 proxyurl = 'http://' + proxyurl + '/'
409 proxyurl = 'http://' + proxyurl + '/'
410 snpqf = urlparse.urlsplit(proxyurl)
410 proxy = url(proxyurl)
411 proxyscheme, proxynetloc, proxypath, proxyquery, proxyfrag = snpqf
411 if not proxy.user:
412 hpup = netlocsplit(proxynetloc)
412 proxy.user = ui.config("http_proxy", "user")
413
413 proxy.passwd = ui.config("http_proxy", "passwd")
414 proxyhost, proxyport, proxyuser, proxypasswd = hpup
415 if not proxyuser:
416 proxyuser = ui.config("http_proxy", "user")
417 proxypasswd = ui.config("http_proxy", "passwd")
418
414
419 # see if we should use a proxy for this url
415 # see if we should use a proxy for this url
420 no_list = ["localhost", "127.0.0.1"]
416 no_list = ["localhost", "127.0.0.1"]
@@ -429,13 +425,10 b' class proxyhandler(urllib2.ProxyHandler)'
429 else:
425 else:
430 self.no_list = no_list
426 self.no_list = no_list
431
427
432 proxyurl = urlparse.urlunsplit((
428 proxyurl = str(proxy)
433 proxyscheme, netlocunsplit(proxyhost, proxyport,
434 proxyuser, proxypasswd or ''),
435 proxypath, proxyquery, proxyfrag))
436 proxies = {'http': proxyurl, 'https': proxyurl}
429 proxies = {'http': proxyurl, 'https': proxyurl}
437 ui.debug('proxying through http://%s:%s\n' %
430 ui.debug('proxying through http://%s:%s\n' %
438 (proxyhost, proxyport))
431 (proxy.host, proxy.port))
439 else:
432 else:
440 proxies = {}
433 proxies = {}
441
434
@@ -602,13 +595,9 b' def _generic_start_transaction(handler, '
602 new_tunnel = False
595 new_tunnel = False
603
596
604 if new_tunnel or tunnel_host == req.get_full_url(): # has proxy
597 if new_tunnel or tunnel_host == req.get_full_url(): # has proxy
605 urlparts = urlparse.urlparse(tunnel_host)
598 u = url(tunnel_host)
606 if new_tunnel or urlparts[0] == 'https': # only use CONNECT for HTTPS
599 if new_tunnel or u.scheme == 'https': # only use CONNECT for HTTPS
607 realhostport = urlparts[1]
600 h.realhostport = ':'.join([u.host, (u.port or '443')])
608 if realhostport[-1] == ']' or ':' not in realhostport:
609 realhostport += ':443'
610
611 h.realhostport = realhostport
612 h.headers = req.headers.copy()
601 h.headers = req.headers.copy()
613 h.headers.update(handler.parent.addheaders)
602 h.headers.update(handler.parent.addheaders)
614 return
603 return
General Comments 0
You need to be logged in to leave comments. Login now