Closed
Description
What version of Go are you using (go version
)?
$ go version go version go1.12.4 darwin/amd64
What did you do?
func serve(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Encoding", "gzip")
gzw := gzip.NewWriter(w)
defer gzw.Close()
io.WriteString(gzw, `<!doctype html><p>Hello</p>`)
}
What did you expect to see?
Content-Type header of "text/html", or none at all.
What did you see instead?
Content-Type header of "application/x-gzip".
Since the content being written to the ResponseWriter is compressed with gzip, the Content-Type is being detected as application/x-gzip.
Content-Type sniffing should be disabled when there is a Content-Encoding header.