Skip to content

Commit 6315923

Browse files
authored
gzhttp: Don't compress HEAD requests (#387)
1 parent 3e13b83 commit 6315923

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

gzhttp/gzip.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,11 @@ func ContentTypeFilter(compress func(ct string) bool) option {
558558
// acceptsGzip returns true if the given HTTP request indicates that it will
559559
// accept a gzipped response.
560560
func acceptsGzip(r *http.Request) bool {
561-
return parseEncodingGzip(r.Header.Get(acceptEncoding)) > 0
561+
// Note that we don't request this for HEAD requests,
562+
// due to a bug in nginx:
563+
// https://trac.nginx.org/nginx/ticket/358
564+
// https://golang.org/issue/5522
565+
return r.Method != http.MethodHead && parseEncodingGzip(r.Header.Get(acceptEncoding)) > 0
562566
}
563567

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

0 commit comments

Comments
 (0)