Merge pull request #3660 from pawelmhm/proxy_empty_pass

[httpAdapter] allow empty password in proxy credentials
This commit is contained in:
Cory Benfield
2016-10-31 13:59:16 +00:00
committed by GitHub
2 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -366,7 +366,7 @@ class HTTPAdapter(BaseAdapter):
headers = {}
username, password = get_auth_from_url(proxy)
if username and password:
if username:
headers['Proxy-Authorization'] = _basic_auth_str(username,
password)
+10
View File
@@ -1472,6 +1472,16 @@ class TestRequests:
proxies['one'].clear.assert_called_once_with()
proxies['two'].clear.assert_called_once_with()
def test_proxy_auth(self, httpbin):
adapter = HTTPAdapter()
headers = adapter.proxy_headers("http://user:pass@httpbin.org")
assert headers == {'Proxy-Authorization': 'Basic dXNlcjpwYXNz'}
def test_proxy_auth_empty_pass(self, httpbin):
adapter = HTTPAdapter()
headers = adapter.proxy_headers("http://user:@httpbin.org")
assert headers == {'Proxy-Authorization': 'Basic dXNlcjo='}
def test_response_json_when_content_is_None(self, httpbin):
r = requests.get(httpbin('/status/204'))
# Make sure r.content is None