-
-
Notifications
You must be signed in to change notification settings - Fork 753
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
uvicorn may respond to requests sent after the client asks for the connection to be closed #2238
Comments
The repro that I provided above has a typo (the first request is missing a Here's a better pipeline that actually demonstrates the bug: printf 'GET / HTTP/1.1\r\nConnection: close\r\nHost: a\r\n\r\nGET / HTTP/1.1\r\n\r\n' | nc localhost 8080 There are two requests in this pipeline; the first is valid and should close the connection. The second is invalid (missing What Uvicorn does is respond to the second request and not the first. |
This comment was marked as spam.
This comment was marked as spam.
I can't tell whether you're supporting this issue or trying to poke a hole in it :) That error isn't necessarily confirmation of the bug; you'd have to look at the server's HTTP response in order to see the bad behavior. |
Confirmed. PR welcome. |
@Kludex do you have a guess about where's the file that needs to be changed? I was thinking on
it looks ok to me so I'm bit confused |
I get below in response. has this issue been fixed already?
|
The issue has not been fixed. I just reproduced it again on the current master branch (latest commit is 1e5f1be at the time of writing). When I send that pipeline, I get the following:
|
+1 to what @berkio3x said, got below response when I tried to run it.
|
We don't need further confirmation. |
Agreed, though I am curious about why others are not able to reproduce the issue. |
I'd be willing to take a shot at fixing this, if nobody else is working on it. I haven't contributed to Uvicorn before though, would there be anything to keep in mind apart from what's in https://www.uvicorn.org/contributing/? |
I was able to reproduce the above issue. Also went through the code of uvicorn and h11. I do have RCA for this problem. NGL this bug is kinda funny lol. Because it'll only occur if you have installed uvicon with Issue: When passed more than one HTTP requests within one single TCP stream, where first request has Observations: This issue only occurs for pip installed uvicorn. Works totally fine with manually installed version. Unless you explicitly set the Reason: pip installed uvicorn uses Possible fix: In the |
Fixed on #2375. Uvicorn 0.30.4 contains the fix. |
Discussed in #2234
Originally posted by kenballus January 28, 2024
Describe the bug
From RFC 9112, section 9.6:
When uvicorn receives a pipeline with a request containing
Connection: close
, followed by an invalid request, uvicorn responds only to the second (invalid) request, even though the standard requires that uvicorn respond only to the first one.To Reproduce
Connection: close
set, followed by an invalid request:Expected behavior
The server should respond only to the first request, and then close the connection.
Logs/tracebacks
Python Version
uvicorn Version
h11 Version
OS
Debian 12 (running in Docker on Arch Linux)
Linux 6.7.2
Additional context
Some other HTTP implementations that handle this correctly:
Apache httpd, Boost::Beast, Daphne, H2O, Lighttpd, Nginx, Tornado, OpenWrt uhttpd, Waitress
Some other HTTP implementations that also have this bug:
Mongoose, aiohttp
Important
The text was updated successfully, but these errors were encountered: