Skip to content
Myr

[httpAdapter] allow empty password in proxy credentials

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

fixes #3659

authored by Pawel Miech · committed by Pawel Miech · parent 7eaa5ee · Browse files · 2 files+11 added−1 removed
This commit

State

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

Diff stats

2 files+11 added−1 removed

  • tests:+10 added−0 removed
  • other:+1 added−1 removed

2 files+11 added−1 removed

modified:requests/adapters.py+1 added-1 removed
364 unmodified lines
365 """366 headers = {}367 username, password = get_auth_from_url(proxy)368369 if username and password:369 if username:370 headers['Proxy-Authorization'] = _basic_auth_str(username,371 password)372373 return headers
130 unmodified lines
modified:tests/test_requests.py+10 added
1470 unmodified lines
1471 session.close()1472 proxies['one'].clear.assert_called_once_with()1473 proxies['two'].clear.assert_called_once_with()14741475 def test_proxy_auth(self, httpbin):1476 adapter = HTTPAdapter()1477 headers = adapter.proxy_headers("http://user:pass@httpbin.org")1478 assert headers == {'Proxy-Authorization': 'Basic dXNlcjpwYXNz'}14791480 def test_proxy_auth_empty_pass(self, httpbin):1481 adapter = HTTPAdapter()1482 headers = adapter.proxy_headers("http://user:@httpbin.org")1483 assert headers == {'Proxy-Authorization': 'Basic dXNlcjo='}14841485 def test_response_json_when_content_is_None(self, httpbin):1486 r = requests.get(httpbin('/status/204'))1487 # Make sure r.content is None1488 r.status_code = 0
485 unmodified lines