Ensure that ASGI 'raw_path' does not include query component of URL. (#2999)
This commit is contained in:
parent
f8981f3d12
commit
90538a3b46
@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
### Fixed
|
||||
|
||||
* Allow URLs where username or password contains unescaped '@'. (#2986)
|
||||
* Ensure ASGI `raw_path` does not include URL query component. (#2999)
|
||||
|
||||
## 0.25.2 (24th November, 2023)
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ class ASGITransport(AsyncBaseTransport):
|
||||
"headers": [(k.lower(), v) for (k, v) in request.headers.raw],
|
||||
"scheme": request.url.scheme,
|
||||
"path": request.url.path,
|
||||
"raw_path": request.url.raw_path,
|
||||
"raw_path": request.url.raw_path.split(b"?")[0],
|
||||
"query_string": request.url.query,
|
||||
"server": (request.url.host, request.url.port),
|
||||
"client": self.client,
|
||||
|
||||
@ -120,6 +120,19 @@ async def test_asgi_raw_path():
|
||||
assert response.json() == {"raw_path": "/user@example.org"}
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_asgi_raw_path_should_not_include_querystring_portion():
|
||||
"""
|
||||
See https://github.com/encode/httpx/issues/2810
|
||||
"""
|
||||
async with httpx.AsyncClient(app=echo_raw_path) as client:
|
||||
url = httpx.URL("http://www.example.org/path?query")
|
||||
response = await client.get(url)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"raw_path": "/path"}
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_asgi_upload():
|
||||
async with httpx.AsyncClient(app=echo_body) as client:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user