996
996
# grok user:password@host:port as well as
997
997
# http://user:password@host:port
999
(scheme, user, password,
1000
host, port, path) = transport.ConnectedTransport._split_url(proxy)
999
parsed_url = transport.ConnectedTransport._split_url(proxy)
1000
if not parsed_url.host:
1002
1001
raise errors.InvalidURL(proxy, 'No host component')
1004
1003
if request.proxy_auth == {}:
1006
1005
# proxied request, intialize. scheme (the authentication scheme)
1007
1006
# and realm will be set by the AuthHandler
1008
1007
request.proxy_auth = {
1009
'host': host, 'port': port,
1010
'user': user, 'password': password,
1008
'host': parsed_url.host,
1009
'port': parsed_url.port,
1010
'user': parsed_url.user,
1011
'password': parsed_url.password,
1012
'protocol': parsed_url.scheme,
1012
1013
# We ignore path since we connect to a proxy
1015
if parsed_url.port is None:
1016
phost = parsed_url.host
1017
phost = host + ':%d' % port
1018
phost = parsed_url.host + ':%d' % parsed_url.port
1018
1019
request.set_proxy(phost, type)
1019
1020
if self._debuglevel >= 3:
1020
1021
print 'set_proxy: proxy set to %s://%s' % (type, phost)
1129
1130
auth['modified'] = False
1130
1131
# Put some common info in auth if the caller didn't
1131
1132
if auth.get('path', None) is None:
1133
host, port, path) = urlutils.parse_url(request.get_full_url())
1134
self.update_auth(auth, 'protocol', protocol)
1135
self.update_auth(auth, 'host', host)
1136
self.update_auth(auth, 'port', port)
1137
self.update_auth(auth, 'path', path)
1133
parsed_url = urlutils.URL.from_string(request.get_full_url())
1134
self.update_auth(auth, 'protocol', parsed_url.scheme)
1135
self.update_auth(auth, 'host', parsed_url.host)
1136
self.update_auth(auth, 'port', parsed_url.port)
1137
self.update_auth(auth, 'path', parsed_url.path)
1138
1138
# FIXME: the auth handler should be selected at a single place instead
1139
1139
# of letting all handlers try to match all headers, but the current
1140
1140
# design doesn't allow a simple implementation.