-
-
Notifications
You must be signed in to change notification settings - Fork 844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ASGI raw_path
scope key should not include the query string portion.
#2810
Comments
It looks like Which means the bug is here: httpx/httpx/_transports/asgi.py Lines 97 to 111 in 9415af6
That's where the |
Accidentally closed this, reopening. |
Hmm, I am not entirely sure how we should resolve this - the web server receives the query string bytes in the same part of the HTTP protocol as the path. If two servers agree, though, that's probably the best way. |
Okay so there's two different aspects here... There's the ASGI scope key httpx/httpx/_transports/asgi.py Lines 97 to 111 in e99e294
Which, appears to be incorrect. Then there's the
See also https://h11.readthedocs.io/en/latest/api.html#h11.Request |
Let's treat this issue as just addressing the ASGI httpx/httpx/_transports/asgi.py Line 106 in e99e294
(Incidentally I think if we'd been really sharp we might have clocked onto this back in django/asgiref#87 and gone with a |
raw_path
scope key should not include the query string portion.
Yeah, I agree it was poorly named - I think I leaned too close to WSGI on this one. Unfortunately, we now have what we have. |
I ran into a bug where I had written code that assumed
raw_path
as provided by Uvicorn would include the query string, where it turns out not to.My tests didn't catch this because they were exercising the code using HTTPX ASGI emulation, and it turns out HTTPX thinks that
raw_path
DOES include the query string.In Uvicorn: https://github.com/encode/uvicorn/blob/93bb8d3879808ae376b57e3721cc227fce2c27c1/uvicorn/protocols/http/h11_impl.py#L207
But in HTTPX:
httpx/httpx/_urls.py
Lines 277 to 292 in 9415af6
I'm pretty confident HTTPX is incorrect about this. The ASGI spec (coincidentally the one bit of it I contributed directly to) says: https://asgi.readthedocs.io/en/latest/specs/www.html#http-connection-scope
On reading it now I realize this is a little ambiguous.
Daphne (the closest we have to a reference implementation of ASGI) backs up the idea that
raw_path
andpath
should be almost identical except for their encoding: https://github.com/django/daphne/blob/e49c39a4e5fac8ec170dd653641a9e90844fd3f1/daphne/ws_protocol.py#L77C1-L78The text was updated successfully, but these errors were encountered: