-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http: server hangs #68382
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
Comments
I believe this is working as intended. Read can be allowed to block. Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only. For questions please refer to https://github.com/golang/go/wiki/Questions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Go version
go version go1.22.2 windows/amd64
Output of
go env
in your module/workspace:What did you do?
Description:
The server hangs when processing POST requests that have a Content-Length greater than zero but an empty body. This issue occurs because the io.ReadAll function waits to read the number of bytes specified in the Content-Length header, leading to a hang when the body is empty.
Steps to Reproduce:
Run the provided server code.
Send a POST request to localhost:55432 with a Content-Length header greater than zero and an empty body.
Example request:
The server hangs on the line request, err := io.ReadAll(r.Body), and after canceling the request, it logs an unexpected EOF error.
Alright, I thought such requests could be handled through context and discarded. However, I tried to do this and encountered another error. It is also related to the request hanging, but this time with a timeout:
The request hangs when attempting to call w.finishRequest() in net/http/server.go.
The call parameters are the same: an empty body and Content-Length > 0.
What am I doing wrong? Is this behavior standard?
What did you see happen?
The server hangs on the line request, err := io.ReadAll(r.Body), and after canceling the request, it logs an unexpected EOF error.
What did you expect to see?
I expected the request to either fail with an error or proceed without hanging
The text was updated successfully, but these errors were encountered: