1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
1
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
1336
1336
def _split_url(url):
1338
Extract the server address, the credentials and the path from the url.
1340
user, password, host and path should be quoted if they contain reserved
1343
:param url: an quoted url
1345
:return: (scheme, user, password, host, port, path) tuple, all fields
1348
if isinstance(url, unicode):
1349
raise errors.InvalidURL('should be ascii:\n%r' % url)
1350
url = url.encode('utf-8')
1351
(scheme, netloc, path, params,
1352
query, fragment) = urlparse.urlparse(url, allow_fragments=False)
1353
user = password = host = port = None
1355
user, host = netloc.rsplit('@', 1)
1357
user, password = user.split(':', 1)
1358
password = urllib.unquote(password)
1359
user = urllib.unquote(user)
1364
host, port = host.rsplit(':', 1)
1368
raise errors.InvalidURL('invalid port number %s in url:\n%s' %
1371
raise errors.InvalidURL('Host empty in: %s' % url)
1373
host = urllib.unquote(host)
1374
path = urllib.unquote(path)
1376
return (scheme, user, password, host, port, path)
1337
return urlutils.parse_url(url)
1379
1340
def _unsplit_url(scheme, user, password, host, port, path):