from collections import Mapping
from datetime import datetime
-from .compat import cookielib, OrderedDict, urljoin, urlparse
+from .compat import cookielib, OrderedDict, urljoin, urlparse, urlunparse
from .cookies import cookiejar_from_dict, extract_cookies_to_jar, RequestsCookieJar
from .models import Request, PreparedRequest
from .hooks import default_hooks, dispatch_hook
url = '%s:%s' % (parsed_rurl.scheme, url)
# The scheme should be lower case...
- if '://' in url:
- scheme, uri = url.split('://', 1)
- url = '%s://%s' % (scheme.lower(), uri)
+ parsed = urlparse(url)
+ parsed = (parsed.scheme.lower(), parsed.netloc, parsed.path,
+ parsed.params, parsed.query, parsed.fragment)
+ url = urlunparse(parsed)
# Facilitate non-RFC2616-compliant 'location' headers
# (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')