← oracle_full

requests_7315

resolved RESOLVED UNSUBMITTED PASS · None tool calls · 0 s · psf/requests

Task input

Preserve leading slashes in request path_url

## Summary
Fixes issue #6711 where S3 presigned URLs with keys starting with '/' were incorrectly modified, breaking URL signatures.
URLs like `https://bucket.s3.amazonaws.com//key_name` now correctly preserve `//key_name` in the path.

## Changes
- Remove URL manipulation that collapsed leading slashes in `request_url()` method
- Add test to verify leading slashes are preserved for S3-style URLs

## Reproduction
```python
import requests

# S3 presigned URL with key starting with '/'
url = "https://bucket.s3.amazonaws.com//key_with_leading_slash.txt"
r = requests.get(url)  # Previously broken, now works correctly
Fixes #6711

Tool calls (0)

#ToolArgumentsResult
No trace captured.

Patch

--- a/src/requests/adapters.py
+++ b/src/requests/adapters.py
@@ -545,8 +545,6 @@ def request_url(self, request, proxies):
             using_socks_proxy = proxy_scheme.startswith("socks")
 
         url = request.path_url
-        if url.startswith("//"):  # Don't confuse urllib3
-            url = f"/{url.lstrip('/')}"
 
         if is_proxied_http_request and not using_socks_proxy:
             url = urldefragauth(request.url)

Test output

show
.                                                                        [100%]
=============================== warnings summary ===============================
../../../../../../../Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/requests/lib/python3.13/site-packages/_pytest/config/__init__.py:1464
  /Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/requests/lib/python3.13/site-packages/_pytest/config/__init__.py:1464: PytestConfigWarning: Unknown config option: timeout
  
    self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
1 passed, 1 warning in 0.01s
[2026-09-23 18:20:44,927] WARNING in core: flasgger is not installed; serving the static landing page at / and skipping the Swagger UI and /spec.json.