Skip to content

Commit

Permalink
remove Content-Type requirement
Browse files Browse the repository at this point in the history
* golang/go#31753 is fixed
  • Loading branch information
Jay Wren committed Feb 25, 2023
1 parent 2848168 commit b7a4cf9
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit b7a4cf9

Please sign in to comment.