]> Cypherpunks repositories - gostls13.git/commit
net/http: don't send implicit gzip Accept-Encoding on Range requests
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 15 Oct 2014 15:51:30 +0000 (17:51 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 15 Oct 2014 15:51:30 +0000 (17:51 +0200)
commit42c3130780327299cb8a89f30b8e5c3d6b96d2c2
tree4d723689cf9ba44e91028c77891eee5d0de37755
parent9d51cd0fee3cf8bf779ba23a34b7fb2ec311cfe1
net/http: don't send implicit gzip Accept-Encoding on Range requests

The http package by default adds "Accept-Encoding: gzip" to outgoing
requests, unless it's a bad idea, or the user requested otherwise.
Only when the http package adds its own implicit Accept-Encoding header
does the http package also transparently un-gzip the response.

If the user requested part of a document (e.g. bytes 40 to 50), it appears
that Github/Varnish send:
        range(gzip(content), 40, 50)

And not:
        gzip(range(content, 40, 50))

The RFC 2616 set of replacements (with the purpose of
clarifying ambiguities since 1999) has an RFC about Range
requests (http://tools.ietf.org/html/rfc7233) but does not
mention the interaction with encodings.

Regardless of whether range(gzip(content)) or gzip(range(content)) is
correct, this change prevents the Go package from asking for gzip
in requests if we're also asking for Range, avoiding the issue.
If the user cared, they can do it themselves. But Go transparently
un-gzipping a fragment of gzip is never useful.

Fixes #8923

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/155420044
src/net/http/response_test.go
src/net/http/transport.go
src/net/http/transport_test.go