Skip to content

Commit

Permalink
gzhttp: Don't compress HEAD requests (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
klauspost authored Jun 3, 2021
1 parent 3e13b83 commit 6315923
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gzhttp/gzip.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,11 @@ func ContentTypeFilter(compress func(ct string) bool) option {
// acceptsGzip returns true if the given HTTP request indicates that it will
// accept a gzipped response.
func acceptsGzip(r *http.Request) bool {
return parseEncodingGzip(r.Header.Get(acceptEncoding)) > 0
// Note that we don't request this for HEAD requests,
// due to a bug in nginx:
// https://trac.nginx.org/nginx/ticket/358
// https://golang.org/issue/5522
return r.Method != http.MethodHead && parseEncodingGzip(r.Header.Get(acceptEncoding)) > 0
}

// returns true if we've been configured to compress the specific content type.
Expand Down

0 comments on commit 6315923

Please sign in to comment.