aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2011-12-14 11:20:21 -0800
committerBrad Fitzpatrick <bradfitz@golang.org>2011-12-14 11:20:21 -0800
commit22dafc9bc5c8b339628a64c9f786491a60031005 (patch)
tree154d22782cedd88bbd66e3d8c1f0511b0b802a30
parent6890afd9a34646b20043d0dffe32cabd0f3ec51c (diff)
downloadgo-22dafc9bc5c8b339628a64c9f786491a60031005.tar.gz
go-22dafc9bc5c8b339628a64c9f786491a60031005.zip
http: fix failing Transport HEAD request with gzip-looking response
We only want to attempt to un-gzip if there's a body (not in response to a HEAD) This was accidentally passing before, but revealed to be broken when c3c6e72d7cc went in. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5477093
-rw-r--r--src/pkg/net/http/transport.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/pkg/net/http/transport.go b/src/pkg/net/http/transport.go
index dc70be43f2..33ad32861b 100644
--- a/src/pkg/net/http/transport.go
+++ b/src/pkg/net/http/transport.go
@@ -539,12 +539,13 @@ func (pc *persistConn) readLoop() {
resp, err := ReadResponse(pc.br, rc.req)
if err == nil {
- if rc.addedGzip && resp.Header.Get("Content-Encoding") == "gzip" {
+ hasBody := rc.req.Method != "HEAD" && resp.ContentLength != 0
+ if rc.addedGzip && hasBody && resp.Header.Get("Content-Encoding") == "gzip" {
resp.Header.Del("Content-Encoding")
resp.Header.Del("Content-Length")
resp.ContentLength = -1
gzReader, zerr := gzip.NewReader(resp.Body)
- if err != nil {
+ if zerr != nil {
pc.close()
err = zerr
} else {