x/net/http2: gzip response not decoded #40774
Comments
Isn't this intended behavior? Automatic decompression only happens if a Transport adds From the
|
Thanks, but please don't send us patches in the issue tracker. Please send them via Gerrit or GitHub, as discussed at https://golang.org/doc/contribute.html. That ensures that the copyright agreements are correct. We can't use or theoretically even look at patches submitted in a GitHub issue. Thanks. |
@cespare in my steps to reproduce I showed how the snippet adds the Accept-Encoding gzip, despite this, the HTTP client does not decode the gzip response, the reason is because http2ClientConn (h2_bundle.go) is only decoding gzip responses if the user has left the Accept-Encoding header empty, which is not appropriate. |
@melardev yes, and I'm saying that behavior is intended. If you don't set the If you do set |
@cespare hm, I see, it looks opaque and strange to me, but I understand your point, I close then. |
Go Version
$ go version
go version go1.13.8 linux/amd64
Summary
Hi, Gzip response is not decoded if the user specifies Accept-Encoding in the request headers manually.
Details
In my previous issue #40765 I was asked to support the
x-gzip
value, looking at the code for how gzip responses are handled I found a bug, first, it was inhttps://github.com/golang/go/blob/master/src/net/http/transport.go#L2503
Then I noticed the same bug is here too:
https://github.com/golang/go/blob/master/src/net/http/h2_bundle.go#L7500
Basically, if the user specifies the Accept-Encoding to gzip, the
requestedGzip
variable won't be set and hence the response won't be decoded.Then the following check is bypassed because requestedGzip is false.
https://github.com/golang/go/blob/master/src/net/http/h2_bundle.go#L8474
Steps to reproduce
To reproduce the bug run the following:
If we remove the line
The code would work fine.
This would be my first contribution to such a big project, can I make a pull request to fix this bug?
The diff file would look like this: (the only difference is that the changes have to be made to the
func (cc *http2ClientConn) roundTrip(*Request)
methodThe text was updated successfully, but these errors were encountered: