]> Cypherpunks repositories - gostls13.git/commit
net/http: remove misleading response headers on error
authorRuss Cox <rsc@golang.org>
Fri, 15 Mar 2024 16:56:23 +0000 (12:56 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 9 May 2024 17:06:47 +0000 (17:06 +0000)
commitdd6dee48b27e35e3d6ba0723b6851b5fe17d1049
tree59cf2eb2b5be2acfdb957a83e3d05ef29f49893e
parent7fcf38d715e544da66ff7686e12cce1ab87525c2
net/http: remove misleading response headers on error

This is a reapply of CL 544019 and CL 569815, but with
less aggressive semantics as discussed in proposal #66343.

Error deletes Content-Encoding, since it is writing the response
and any preset encoding may not be correct.

On the error-serving path in ServeContent/ServeFile/ServeFS,
these functions delete additional headers: Etag, Last-Modified,
and Cache-Control. The caller may have set these intending
them for the success response, and they may well not be correct
for error responses.

Fixes #50905.
Fixes #66343.

Change-Id: I873d33edde1805990ca16d85ea8d7735b7448626
Reviewed-on: https://go-review.googlesource.com/c/go/+/571995
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/net/http/fs.go
src/net/http/fs_test.go
src/net/http/serve_test.go
src/net/http/server.go