Fix from SF patch #527518: proxy config with user+pass authentication.

Bug fix candidate.
This commit is contained in:
Jeremy Hylton 2002-07-07 16:57:35 +00:00
parent a6269a8ec5
commit 144dea3e05

View file

@ -458,8 +458,11 @@ class ProxyHandler(BaseHandler):
host, XXX = splithost(r_type) host, XXX = splithost(r_type)
if '@' in host: if '@' in host:
user_pass, host = host.split('@', 1) user_pass, host = host.split('@', 1)
user_pass = base64.encodestring(unquote(user_pass)).strip() if ':' in user_pass:
req.add_header('Proxy-Authorization', 'Basic '+user_pass) user, password = user_pass.split(':', 1)
user_pass = base64.encodestring('%s:%s' % (unquote(user),
unquote(password)))
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:
@ -764,7 +767,9 @@ class AbstractHTTPHandler(BaseHandler):
except socket.error, err: except socket.error, err:
raise URLError(err) raise URLError(err)
h.putheader('Host', host) scheme, sel = splittype(req.get_selector())
sel_host, sel_path = splithost(sel)
h.putheader('Host', sel_host or host)
for args in self.parent.addheaders: for args in self.parent.addheaders:
h.putheader(*args) h.putheader(*args)
for k, v in req.headers.items(): for k, v in req.headers.items():