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: Response.Write has bogus Connection header after auto-ungzipped Content-Length response #15366

Closed
sbadame opened this issue Apr 19, 2016 · 3 comments
Milestone

Comments

@sbadame
Copy link

sbadame commented Apr 19, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version go1.6 linux/amd64
  2. What operating system and processor architecture are you using (go env)?
    GOARCH="amd64"
    GOBIN=""
    GOEXE=""
    GOHOSTARCH="amd64"
    GOHOSTOS="linux"
    GOOS="linux"
    GOPATH=""
    GORACE=""
    GOROOT="/usr/lib/google-golang"
    GOTOOLDIR="/usr/lib/google-golang/pkg/tool/linux_amd64"
    GO15VENDOREXPERIMENT="1"
    CC="gcc"
    GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -gno-record-gcc-switches -fdebug-prefix-map=/tmp/go-build052263605=/tmp/go-build"
    CXX="g++"
    CGO_ENABLED="1"
  3. What did you do?
    I can't use the playground because this requires localhost, which the playground doesn't support.
    https://gist.github.com/sbadame/6672153feb5a5430a0129d40b263d8e9
  4. What did you expect to see?
    Either "Connection: close" or "Connection:keep-alive" and a content length. Or maybe chunk encoding?
  5. What did you see instead?

http.Transport.RoundTrip response: HTTP/1.1 200 OK
Connection: close
Connection: keep-alive
Keep-Alive: timeout=7200

http.DefaultClient.Do Response: HTTP/1.1 200 OK
Connection: close
Connection: keep-alive
Keep-Alive: timeout=7200

@gopherbot
Copy link

CL https://golang.org/cl/22671 mentions this issue.

gopherbot pushed a commit that referenced this issue May 1, 2016
The Transport's automatic gzip uncompression lost information in the
process (the compressed Content-Length, if known). Normally that's
okay, but it's not okay for reverse proxies which have to be able to
generate a valid HTTP response from the Transport's provided
*Response.

Reverse proxies should normally be disabling compression anyway and
just piping the compressed pipes though and not wasting CPU cycles
decompressing them. So also document that on the new Uncompressed
field.

Then, using the new field, fix Response.Write to not inject a bogus
"Connection: close" header when it doesn't see a transfer encoding or
content-length.

Updates #15366 (the http2 side remains, once this is submitted)

Change-Id: I476f40aa14cfa7aa7b3bf99021bebba4639f9640
Reviewed-on: https://go-review.googlesource.com/22671
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@gopherbot
Copy link

CL https://golang.org/cl/23002 mentions this issue.

gopherbot pushed a commit to golang/net that referenced this issue May 10, 2016
Go 1.7 introduces Request.Context and Response.Uncompressed. Use them
both in the http2 Transport when building for Go 1.7.

Tests are in the main repo.

Updates golang/go#15366
Updates golang/go#15134

Change-Id: I4b78a2710b6cf30c769c7f85cea15ecde653a317
Reviewed-on: https://go-review.googlesource.com/23002
Reviewed-by: Andrew Gerrand <adg@golang.org>
@gopherbot
Copy link

CL https://golang.org/cl/23003 mentions this issue.

@golang golang locked and limited conversation to collaborators May 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants