mirror of
https://github.com/golang/go
synced 2024-11-24 19:00:13 -07:00
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
This commit is contained in:
parent
6890afd9a3
commit
22dafc9bc5
@ -539,12 +539,13 @@ func (pc *persistConn) readLoop() {
|
|||||||
resp, err := ReadResponse(pc.br, rc.req)
|
resp, err := ReadResponse(pc.br, rc.req)
|
||||||
|
|
||||||
if err == nil {
|
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-Encoding")
|
||||||
resp.Header.Del("Content-Length")
|
resp.Header.Del("Content-Length")
|
||||||
resp.ContentLength = -1
|
resp.ContentLength = -1
|
||||||
gzReader, zerr := gzip.NewReader(resp.Body)
|
gzReader, zerr := gzip.NewReader(resp.Body)
|
||||||
if err != nil {
|
if zerr != nil {
|
||||||
pc.close()
|
pc.close()
|
||||||
err = zerr
|
err = zerr
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user