Skip to content
Myr

Fixed bug to give scheme proxy priority over "all"

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

authored by Michael Hunsinger · committed by Michael Hunsinger · parent d3567aa · Browse files · 3 files+11 added−2 removed
This commit

State

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

Diff stats

3 files+11 added−2 removed

  • tests:+8 added−0 removed
  • other:+3 added−2 removed

3 files+11 added−2 removed

modified:requests/utils.py+2 added-2 removed
618 unmodified lines
619 if urlparts.hostname is None:620 return proxies.get('all', proxies.get(urlparts.scheme))621622 proxy_keys = [623 'all://' + urlparts.hostname,624 'all',623 urlparts.scheme + '://' + urlparts.hostname,624 urlparts.scheme,625 'all://' + urlparts.hostname,626 'all',627 ]628 proxy = None629 for proxy_key in proxy_keys:630 if proxy_key in proxies:
187 unmodified lines
modified:tests/test_utils.py+8 added
321 unmodified lines
322http_proxies = {'http': 'http://http.proxy',323 'http://some.host': 'http://some.host.proxy'}324all_proxies = {'all': 'socks5://http.proxy',325 'all://some.host': 'socks5://some.host.proxy'}326mixed_proxies = {'http': 'http://http.proxy',327 'http://some.host': 'http://some.host.proxy',328 'all': 'socks5://http.proxy'}329@pytest.mark.parametrize(330 'url, expected, proxies', (331 ('hTTp://u:p@Some.Host/path', 'http://some.host.proxy', http_proxies),332 ('hTTp://u:p@Other.Host/path', 'http://http.proxy', http_proxies),
5 unmodified lines
338 ('hTTp://u:p@Other.Host/path', 'socks5://http.proxy', all_proxies),339 ('hTTp:///path', 'socks5://http.proxy', all_proxies),340 ('hTTps://Other.Host', 'socks5://http.proxy', all_proxies),341342 ('http://u:p@other.host/path', 'http://http.proxy', mixed_proxies),343 ('http://u:p@some.host/path', 'http://some.host.proxy', mixed_proxies),344 ('https://u:p@other.host/path', 'socks5://http.proxy', mixed_proxies),345 ('https://u:p@some.host/path', 'socks5://http.proxy', mixed_proxies),346 347 # XXX: unsure whether this is reasonable behavior348 ('file:///etc/motd', 'socks5://http.proxy', all_proxies),349 ))350def test_select_proxies(url, expected, proxies):
125 unmodified lines
modified:AUTHORS.rst+1 added
166 unmodified lines
167- piotrjurkiewicz168- Jesse Shapiro <jesse@jesseshapiro.net> (`@haikuginger <https://github.com/haikuginger>`_)169- Nate Prewitt <nate.prewitt@gmail.com> (`@nateprewitt <https://github.com/nateprewitt>`_)170- Maik Himstedt171- Michael Hunsinger