Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: HTTP transport automatic unzipping appears to not properly work if Content-Encoding reply header isn't lowercase gzip #19248

GuySirton opened this issue Feb 23, 2017 · 3 comments


Copy link

@GuySirton GuySirton commented Feb 23, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?


What operating system and processor architecture are you using (go env)?

linux; amd64

What did you do?

Used a Go application binary that uses an HTTP client to retrieve data from an in-house/custom HTTP server. Examined network traffic.
The Go application specifies: "Accept-Encoding: gzip"
The server replies with "Content-Encoding: GZIP" and a gzipped reply (note the uppercase).

What did you expect to see?

Expected the Go application to unzip the data.

What did you see instead?

It appears the data didn't get unzipped and the application logic failed as a result of that. When the in-house server was modified to reply with a lowecase "gzip" the Go application unzipped the stream and the application logic worked.

The root cause may be this:
if rc.addedGzip && resp.Header.Get("Content-Encoding") == "gzip" {

RFC2616 section 3.5 specifies: "All content-coding values are case-insensitive." so it seems that the client is not fully compliant?

Copy link

@odeke-em odeke-em commented Feb 23, 2017

/cc @bradfitz

@bradfitz bradfitz added this to the Go1.9 milestone Feb 23, 2017
Copy link

@JanBerktold JanBerktold commented Feb 23, 2017

Unless I am missing something, this should be quite easy to fix.

I will take care of this.

Copy link

@gopherbot gopherbot commented Feb 23, 2017

CL mentions this issue.

@gopherbot gopherbot closed this in 51b2213 May 24, 2017
@golang golang locked and limited conversation to collaborators May 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants