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: ServeContent serves wrong headers if request range is invalid #50905
Comments
Change https://go.dev/cl/381956 mentions this issue: |
The reference was by a mistake. It is unrelated (or, partially related, but I do not think enough to be linked). |
ServeContent API is to set some headers you want to see in the response before calling ServeContent. But if there is an error, those headers should be removed otherwise they might confused the client. Fixes golang#50905.
ServeContent API is to set some headers you want to see in the response before calling ServeContent. But if there is an error, those headers should be removed otherwise they might confused the client. Fixes golang#50905.
Change https://go.dev/cl/544019 mentions this issue: |
I agree that (Commented further on https://go.dev/cl/544019.) |
ServeContent API is to set some headers you want to see in the response before calling ServeContent. But if there is an error, those headers should be removed otherwise they might confused the client. Fixes golang#50905.
ServeContent API is to set some headers you want to see in the response before calling ServeContent. But if there is an error, those headers should be removed otherwise they might confused the client. Fixes golang#50905.
Change https://go.dev/cl/554216 mentions this issue: |
Error replies to a request with an error message and HTTP code. Delete any preexisting Content-Length header before writing the header; if a Content-Length is present, it's probably for content that the caller has given up on writing. For #50905 Change-Id: Ia3d4ca008be46fa5d41afadf29ca5cacb1c47660 Reviewed-on: https://go-review.googlesource.com/c/go/+/554216 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
ServeContent API is to set some headers you want to see in the response before calling ServeContent. But if there is an error, those headers should be removed otherwise they might confuse the client. Removing those headers is useful in general in the case of an error, so we remove them in http.Error. Fixes golang#50905.
ServeContent API is to set some headers you want to see in the response before calling ServeContent. But if there is an error, those headers should be removed otherwise they might confuse the client. Removing those headers is useful in general in the case of an error, so we remove them in http.Error. Fixes golang#50905.
ServeContent API is to set some headers you want to see in the response before calling ServeContent. But if there is an error, those headers should be removed otherwise they might confuse the client. Removing those headers is useful in general in the case of an error, so we remove them in http.Error. Fixes golang#50905.
Change https://go.dev/cl/569815 mentions this issue: |
CL 544019 changes http.Error to remove misleading response headers. However, it also adds new "Cache-Control" header unconditionally, which may breaks existing clients out there, who do not expect to see the this header in the response like test in golang.org/x/net/http2. To keep thing backward compatible, http.Error should only add Cache-Control header if it has been presented. Updates #50905 Change-Id: I989e9f999a30ec170df4fb28905f50aed0267dad Reviewed-on: https://go-review.googlesource.com/c/go/+/569815 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com>
Reverting this change because it is breaking tests and needs more careful consideration and a godebug if we decide to move forward again. |
Change https://go.dev/cl/571975 mentions this issue: |
Change https://go.dev/cl/571995 mentions this issue: |
This reverts CL 544019 and CL 569815, because they break a variety of tests inside Google that do not expect the Cache-Control header to be set to no-cache. A followup CL will add this functionality back after a proposal. For #50905. Change-Id: Ie377bfb72ce2c77d11bf31f9617ab6db342a408a Reviewed-on: https://go-review.googlesource.com/c/go/+/571975 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Proposal discussion at #66343. |
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?
I am serving a static blob using
ServeContent
, setting bothContent-Length
andEtag
:Setting
Etag
andContent-Length
is recommended way to set those headers if one wants them.When making an invalid range request, e.g., for a blob of 586 bytes, I do:
What did you expect to see?
What did you see instead?
There is:
Content-Length
header.Etag
does not really hold for this content, so it should be removed.Content-Range
is in fact valid, see #15798.The text was updated successfully, but these errors were encountered: