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
net/http: server not setting Content-Length in certain cases #44953
Comments
/cc @neild I'll look into the playground timeouts separately. |
This seems to be incorrect behavior in Go 1.16 based on the documented http.ResponseWriter.Write behavior:
|
This is caused by CL 249238, which changes I think this is a bug in that CL; content-detection should read up to 512 bytes, issuing multiple reads if necessary. |
Change https://golang.org/cl/301449 mentions this issue: |
@gopherbot please backport to 1.16; this is a regression. |
Backport issue(s) opened: #44984 (for 1.16). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
Any updates on landing the fix to this? It's still in the Go 1.17 milestone, and this appears to be a regression. Its backport has already been approved. |
Change https://golang.org/cl/324971 mentions this issue: |
…ort reads CL 249238 changes ResponseWriter.ReadFrom to probe the source with a single read of sniffLen bytes before writing the response header. If the source returns less than sniffLen bytes without reaching EOF, this can cause Content-Type and Content-Length detection to fail. Fix ResponseWrite.ReadFrom to copy a full sniffLen bytes from the source as a probe. Drop the explicit call to w.WriteHeader; writing the probe will trigger a WriteHeader call. Consistently use io.CopyBuffer; ReadFrom has already acquired a copy buffer, so it may as well use it. Fixes #44984. Updates #44953. Change-Id: Ic49305fb827a2bd7da4764b68d64b797b5157dc0 Reviewed-on: https://go-review.googlesource.com/c/go/+/301449 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> (cherry picked from commit 831f937) Reviewed-on: https://go-review.googlesource.com/c/go/+/324971 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://play.golang.org/p/w-t_Fq5N2JD (not runnable ATM due to playground issue).
What did you expect to see?
"Content-Length" set to 1 in the response, as in Go 1.15.
What did you see instead?
"Content-Length" not set in the response.
The text was updated successfully, but these errors were encountered: