diff --git a/requests/sessions.py b/requests/sessions.py index bcbcc880..38fa2880 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -226,7 +226,7 @@ class SessionRedirectMixin(object): if self.trust_env and not should_bypass_proxies(url): environ_proxies = get_environ_proxies(url) - proxy = environ_proxies.get('all', environ_proxies.get(scheme)) + proxy = environ_proxies.get(scheme, environ_proxies.get('all')) if proxy: new_proxies.setdefault(scheme, proxy) diff --git a/requests/utils.py b/requests/utils.py index e0bb3e7c..149b7a0d 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -617,7 +617,7 @@ def select_proxy(url, proxies): proxies = proxies or {} urlparts = urlparse(url) if urlparts.hostname is None: - return proxies.get('all', proxies.get(urlparts.scheme)) + return proxies.get(urlparts.scheme, proxies.get('all')) proxy_keys = [ urlparts.scheme + '://' + urlparts.hostname, diff --git a/tests/test_utils.py b/tests/test_utils.py index b4fc9483..03cff7a6 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -343,7 +343,7 @@ mixed_proxies = {'http': 'http://http.proxy', ('http://u:p@some.host/path', 'http://some.host.proxy', mixed_proxies), ('https://u:p@other.host/path', 'socks5://http.proxy', mixed_proxies), ('https://u:p@some.host/path', 'socks5://http.proxy', mixed_proxies), - + ('https://', 'socks5://http.proxy', mixed_proxies), # XXX: unsure whether this is reasonable behavior ('file:///etc/motd', 'socks5://http.proxy', all_proxies), ))