diff --git a/requests/models.py b/requests/models.py index 19bcd073..2608e246 100644 --- a/requests/models.py +++ b/requests/models.py @@ -391,7 +391,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): return host - def prepare_url(self, url, params): + def prepare_url(self, url, params, validate=False): """Prepares the given HTTP URL.""" # : Accept objects that have string representations. #: We're unable to blindly call unicode/str functions @@ -414,13 +414,11 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): # Support for unicode domain names and paths. try: uri = rfc3986.urlparse(url) - rfc3986.normalize_uri(url) + if validate: + rfc3986.normalize_uri(url) except rfc3986.exceptions.RFC3986Exception: raise InvalidURL("Invalid URL %r: URL is imporoper." % url) - - - if not uri.scheme: error = ( "Invalid URL {0!r}: No scheme supplied. Perhaps you meant http://{0}?"