-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: net/http: accept "x-gzip" content encoding value #40765
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
Comments
@melardev are you experiencing this in the wild? Which servers still serve x-gzip as their content-encoding? |
@andybons actually not, but I was trying to write some HTTP client code for HTTP 0.9 and reviewing the RFC this showed up, I asked myself if the remote server returns such response, would be golang able to decode it or not, looking at the code it seems there may be an issue if that code path is triggered, so I wanted to ask here if it would be interesting to add support for it and see what you think about that. |
Also, I don't know exactly when that function is being triggered, by default using HttpClient.Do() it is not, it would be interesting to know what would have happened if the client already adds the header "Accept-Encoding" to "gzip", the code as of now, it would not set the |
@andybons Digging a little bit further I detected a bug indeed, this same code is at h2_bundle.go which has a copy paste code (as the comment also state): client := http.Client{}
request, err := http.NewRequest("GET", "https://httpbin.org/gzip", nil)
request.Header.Set("Accept-Encoding", "gzip")
if err != nil {
log.Fatalln(err)
}
resp, err := client.Do(request)
if err != nil {
log.Fatalln(err)
}
content, _ := ioutil.ReadAll(resp.Body)
// Garbage will be printed, gzip is not decoded!
log.Println(string(content)) If we remove the line
The code would work fine. |
We are not trying to support HTTP/0.9 - we removed support for it. |
@rsc Hi, no I don't have a real-word use case, I just read that reviewing the HTTP 0.9 spec, I think we can close the issue then. |
Based on the discussion above, this seems like a likely decline. |
No change in consensus, so declined. |
Hi, would it be good if I submit the following diff file?
It basically treats x-gzip as gzip, as noted in the HTTP 0.9 RFC: https://www.ietf.org/rfc/rfc1945.txt section 3.5
For the request header, that may not be that important, but for the response it may save more than one response from legacy servers.
The text was updated successfully, but these errors were encountered: