Commit 531cebad authored by Georg Brandl's avatar Georg Brandl

Bug #902075: urllib2 now handles "host:port" proxy specifications


Can/should this be backported?
parent 3d563509
...@@ -579,14 +579,19 @@ class ProxyHandler(BaseHandler): ...@@ -579,14 +579,19 @@ class ProxyHandler(BaseHandler):
def proxy_open(self, req, proxy, type): def proxy_open(self, req, proxy, type):
orig_type = req.get_type() orig_type = req.get_type()
type, r_type = splittype(proxy) type, r_type = splittype(proxy)
host, XXX = splithost(r_type) if not type or r_type.isdigit():
if '@' in host: # proxy is specified without protocol
user_pass, host = host.split('@', 1) type = orig_type
if ':' in user_pass: host = proxy
user, password = user_pass.split(':', 1) else:
user_pass = base64.encodestring('%s:%s' % (unquote(user), host, r_host = splithost(r_type)
unquote(password))).strip() user_pass, host = splituser(host)
req.add_header('Proxy-authorization', 'Basic ' + user_pass) user, password = splitpasswd(user_pass)
if user and password:
user, password = user_pass.split(':', 1)
user_pass = base64.encodestring('%s:%s' % (unquote(user),
unquote(password))).strip()
req.add_header('Proxy-authorization', 'Basic ' + user_pass)
host = unquote(host) host = unquote(host)
req.set_proxy(host, type) req.set_proxy(host, type)
if orig_type == type: if orig_type == type:
......
...@@ -337,7 +337,9 @@ Extension Modules ...@@ -337,7 +337,9 @@ Extension Modules
Library Library
------- -------
- Bug #1407902: Added support for sftp:// URIs to urlparse. - Bug #902075: urllib2 now supports 'host:port' style proxy specifications.
- Bug #1407902: Add support for sftp:// URIs to urlparse.
- Bug #1371247: Update Windows locale identifiers in locale.py. - Bug #1371247: Update Windows locale identifiers in locale.py.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment