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>
h.Del("Etag")
h.Del("Last-Modified")
// There might be cache control headers set for some other content,
- // but we reset it to no-cache for the error content.
- h.Set("Cache-Control", "no-cache")
+ // but we reset it to no-cache for the error content if presents.
+ if h.has("Cache-Control") {
+ h.Set("Cache-Control", "no-cache")
+ }
// There might be content type already set, but we reset it to
// text/plain for the error message.
h.Set("Content-Type", "text/plain; charset=utf-8")