mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 14:50:16 +00:00
Fix auth parsing for proxies
Co-authored-by: adamp01 <@adamp01>
This commit is contained in:
@@ -974,6 +974,10 @@ def prepend_scheme_if_needed(url, new_scheme):
|
||||
if not netloc:
|
||||
netloc, path = path, netloc
|
||||
|
||||
if auth:
|
||||
# parse_url doesn't provide the netloc with auth
|
||||
# so we'll add it ourselves.
|
||||
netloc = '@'.join([auth, netloc])
|
||||
if scheme is None:
|
||||
scheme = new_scheme
|
||||
if path is None:
|
||||
|
||||
@@ -602,6 +602,14 @@ def test_parse_header_links(value, expected):
|
||||
('example.com/path', 'http://example.com/path'),
|
||||
('//example.com/path', 'http://example.com/path'),
|
||||
('example.com:80', 'http://example.com:80'),
|
||||
(
|
||||
'http://user:pass@example.com/path?query',
|
||||
'http://user:pass@example.com/path?query'
|
||||
),
|
||||
(
|
||||
'http://user@example.com/path?query',
|
||||
'http://user@example.com/path?query'
|
||||
)
|
||||
))
|
||||
def test_prepend_scheme_if_needed(value, expected):
|
||||
assert prepend_scheme_if_needed(value, 'http') == expected
|
||||
|
||||
Reference in New Issue
Block a user