Fix assumed hostname when using a 'file' URI scheme adapter

This commit is contained in:
Kale Franz
2018-07-05 17:52:19 -05:00
parent dffd5d435e
commit 8023a01dba
2 changed files with 5 additions and 0 deletions
+4
View File
@@ -706,6 +706,10 @@ def should_bypass_proxies(url, no_proxy):
no_proxy = get_proxy('no_proxy')
parsed = urlparse(url)
if parsed.hostname is None:
# URLs don't always have hostnames, e.g. file:/// urls.
return True
if no_proxy:
# We need to check whether we match here. We need to see if we match
# the end of the hostname, both with and without the port.
+1
View File
@@ -622,6 +622,7 @@ def test_urldefragauth(url, expected):
('http://172.16.1.12/', False),
('http://172.16.1.12:5000/', False),
('http://google.com:5000/v1.0/', False),
('file:///some/path/on/disk', True),
))
def test_should_bypass_proxies(url, expected, monkeypatch):
"""Tests for function should_bypass_proxies to check if proxy