mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #3660 from pawelmhm/proxy_empty_pass
[httpAdapter] allow empty password in proxy credentials
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user