Skip to content
Myr

Preserve leading slashes in request path_url (#7315)

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

---------

authored by typhon8 · committed by GitHub · parent e8d2c01 · Browse files · 2 files+2 added−4 removed
This commit

State

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

Trailers

  • Co-authored-by: Nate Prewitt <nate.prewitt@gmail.com>

Diff stats

2 files+2 added−4 removed

  • tests:+2 added−2 removed
  • other:+0 added−2 removed

2 files+2 added−4 removed

modified:src/requests/adapters.py-2 removed
588 unmodified lines
589 proxy_scheme = urlparse(proxy).scheme.lower()590 using_socks_proxy = proxy_scheme.startswith("socks")591592 url = request.path_url593 if url.startswith("//"): # Don't confuse urllib3594 url = f"/{url.lstrip('/')}"593594 if is_proxied_http_request and not using_socks_proxy:595 url = urldefragauth(request.url)596
152 unmodified lines
modified:tests/test_adapters.py+2 added-2 removed
1import requests.adapters234def test_request_url_trims_leading_path_separators():4def test_request_url_handles_leading_path_separators():5 """See also https://github.com/psf/requests/issues/6643."""6 a = requests.adapters.HTTPAdapter()7 p = requests.Request(method="GET", url="http://127.0.0.1:10000//v:h").prepare()8 assert "/v:h" == a.request_url(p, {})8 assert "//v:h" == a.request_url(p, {})