Skip to content
Myr

Revert "Proxy urls should have explicit schemes."

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This reverts commit 840540b6b1f07ef87faab73392c03fbef0dcc9fe. Conflicts: requests/adapters.py requests/utils.py

authored by schlamar · committed by schlamar · parent e909a92 · Browse files · 2 files+15 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+15 added−10 removed

  • other:+15 added−10 removed

2 files+15 added−10 removed

modified:requests/adapters.py+2 added-2 removed
14 unmodified lines
15from .packages.urllib3.response import HTTPResponse16from .packages.urllib3.util import Timeout as TimeoutSauce17from .compat import urlparse, basestring, urldefrag, unquote18from .utils import (DEFAULT_CA_BUNDLE_PATH, get_encoding_from_headers,19 except_on_missing_scheme, get_auth_from_url)19 prepend_scheme_if_needed, get_auth_from_url)20from .structures import CaseInsensitiveDict21from .packages.urllib3.exceptions import MaxRetryError22from .packages.urllib3.exceptions import TimeoutError23from .packages.urllib3.exceptions import SSLError as _SSLError
178 unmodified lines
202 proxies = proxies or {}203 proxy = proxies.get(urlparse(url.lower()).scheme)204205 if proxy:206 except_on_missing_scheme(proxy)206 proxy = prepend_scheme_if_needed(proxy, urlparse(url.lower()).scheme)207 proxy_headers = self.proxy_headers(proxy)208209 if not proxy in self.proxy_manager:210 self.proxy_manager[proxy] = proxy_from_url(
186 unmodified lines
modified:requests/utils.py+13 added-8 removed
22 unmodified lines
23from . import __version__24from . import certs25from .compat import parse_http_list as _parse_list_header26from .compat import (quote, urlparse, bytes, str, OrderedDict, unquote, is_py2,27 builtin_str, getproxies, proxy_bypass)27 builtin_str, getproxies, proxy_bypass, urlunparse)28from .cookies import RequestsCookieJar, cookiejar_from_dict29from .structures import CaseInsensitiveDict30from .exceptions import MissingSchema, InvalidURL30from .exceptions import InvalidURL3132_hush_pyflakes = (RequestsCookieJar,)3334NETRC_FILES = ('.netrc', '_netrc')
586 unmodified lines
621 # Did not detect a valid UTF-32 ascii-range character622 return None623624625def except_on_missing_scheme(url):626 """Given a URL, raise a MissingSchema exception if the scheme is missing.627 """628 scheme, netloc, path, params, query, fragment = urlparse(url)625def prepend_scheme_if_needed(url, new_scheme):626 '''Given a URL that may or may not have a scheme, prepend the given scheme.627 Does not replace a present scheme with the one provided as an argument.'''628 scheme, netloc, path, params, query, fragment = urlparse(url, new_scheme)629630 if not scheme:631 raise MissingSchema('Proxy URLs must have explicit schemes.')630 # urlparse is a finicky beast, and sometimes decides that there isn't a631 # netloc present. Assume that it's being over-cautious, and switch netloc632 # and path if urlparse decided there was no netloc.633 if not netloc:634 netloc, path = path, netloc635636 return urlunparse((scheme, netloc, path, params, query, fragment))637638639def get_auth_from_url(url):640 """Given a url with authentication components, extract them into a tuple of641 username,password."""642 parsed = urlparse(url)
26 unmodified lines