remove Content-Type requirement

* https://github.com/golang/go/issues/31753 is fixed
This commit is contained in:
Jay Wren 2023-02-25 11:50:08 -05:00
parent 2848168f55
commit b7a4cf9ec5
No known key found for this signature in database
1 changed files with 0 additions and 8 deletions

View File

@ -11,15 +11,7 @@ import (
// the Accept-Encoding header, sets the Content-Encoding header, and returns a
// WriteCloser that implements that compression. The Close method must be called
// before the current HTTP handler returns.
//
// Due to https://github.com/golang/go/issues/31753, the response will not be
// compressed unless you set a Content-Type header before you call
// HTTPCompressor.
func HTTPCompressor(w http.ResponseWriter, r *http.Request) io.WriteCloser {
if w.Header().Get("Content-Type") == "" {
return nopCloser{w}
}
if w.Header().Get("Vary") == "" {
w.Header().Set("Vary", "Accept-Encoding")
}