Fix auth parsing for proxies

Co-authored-by: adamp01 <@adamp01>
This commit is contained in:
Nate Prewitt
2022-01-04 08:26:59 -07:00
parent 0192aac241
commit 38f3f8ecb9
2 changed files with 12 additions and 0 deletions
+4
View File
@@ -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:
+8
View File
@@ -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