[httpAdapter] allow empty password in proxy credentials

fixes #3659
This commit is contained in:
Pawel Miech
2016-10-31 14:42:01 +01:00
parent 7eaa5ee37f
commit c97a530638
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