diff options
author | Brad Fitzpatrick <bradfitz@golang.org> | 2013-05-21 15:21:30 -0700 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2013-05-21 15:21:30 -0700 |
commit | aa333f4feb559bab53750ae9c5516425b899b7b4 (patch) | |
tree | 1575216a52c08fd7f0a85ea3d695fe5494b46bf0 /src/pkg/net/http/transport.go | |
parent | 1405bc37e82612e7a46041d1a16407a6e0bc1348 (diff) | |
download | go-aa333f4feb559bab53750ae9c5516425b899b7b4.tar.gz |
net/http: don't send Accept-Encoding on HEAD requests
Works around a bug in nginx: http://trac.nginx.org/nginx/ticket/358
Fixes Issue 5522
R=iant
CC=gobot, golang-dev
https://codereview.appspot.com/9627043
Diffstat (limited to 'src/pkg/net/http/transport.go')
-rw-r--r-- | src/pkg/net/http/transport.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/pkg/net/http/transport.go b/src/pkg/net/http/transport.go index 4cd0533ff..41ac7dea1 100644 --- a/src/pkg/net/http/transport.go +++ b/src/pkg/net/http/transport.go @@ -831,10 +831,15 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err // uncompress the gzip stream if we were the layer that // requested it. requestedGzip := false - if !pc.t.DisableCompression && req.Header.Get("Accept-Encoding") == "" { + if !pc.t.DisableCompression && req.Header.Get("Accept-Encoding") == "" && req.Method != "HEAD" { // Request gzip only, not deflate. Deflate is ambiguous and // not as universally supported anyway. // See: http://www.gzip.org/zlib/zlib_faq.html#faq38 + // + // Note that we don't request this for HEAD requests, + // due to a bug in nginx: + // http://trac.nginx.org/nginx/ticket/358 + // http://golang.org/issue/5522 requestedGzip = true req.extraHeaders().Set("Accept-Encoding", "gzip") } |