40
40
ConnectedTransport,
43
# TODO: This is not used anymore by HttpTransport_urllib
44
# (extracting the auth info and prompting the user for a password
45
# have been split), only the tests still use it. It should be
46
# deleted and the tests rewritten ASAP to stay in sync.
47
def extract_auth(url, password_manager):
48
"""Extract auth parameters from am HTTP/HTTPS url and add them to the given
49
password manager. Return the url, minus those auth parameters (which
52
if not re.match(r'^(https?)(\+\w+)?://', url):
54
'invalid absolute url %r' % (url,))
55
scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
58
auth, netloc = netloc.split('@', 1)
60
username, password = auth.split(':', 1)
62
username, password = auth, None
64
host = netloc.split(':', 1)[0]
67
username = urlutils.unquote(username)
68
if password is not None:
69
password = urlutils.unquote(password)
71
password = ui.ui_factory.get_password(
72
prompt=u'HTTP %(user)s@%(host)s password',
73
user=username, host=host)
74
password_manager.add_password(None, host, username, password)
75
url = urlparse.urlunsplit((scheme, netloc, path, query, fragment))
79
44
class HttpTransportBase(ConnectedTransport):
80
45
"""Base class for http implementations.