summaryrefslogtreecommitdiff
path: root/src/pkg/net/http/transport.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2013-03-30 22:59:08 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2013-03-30 22:59:08 -0700
commitff1218d961ba8b1a680a0bbe469e457e971b2c38 (patch)
tree938a2c442e4c5eb1e01ec94af83090c101fd5151 /src/pkg/net/http/transport.go
parent195341a8d98fce4cc6ccff8b48130076ed470eab (diff)
downloadgo-ff1218d961ba8b1a680a0bbe469e457e971b2c38.tar.gz
net/http: Transport: be paranoid about any non-100 1xx response
Since we can't properly handle anything except 100, treat all 1xx informational responses as sketchy and don't reuse the connection for future requests. The only other 1xx response code currently in use in the wild is WebSockets' use of "101 Switching Protocols", but our code.google.com/p/go.net/websockets doesn't use Client or Transport: it uses ReadResponse directly, so is unaffected by this CL. (and its tests still pass) So this CL is entirely just future-proofing paranoia. Also: the Internet is weird. Update Issue 2184 Update Issue 3665 R=golang-dev, dsymonds CC=golang-dev https://codereview.appspot.com/8208043
Diffstat (limited to 'src/pkg/net/http/transport.go')
-rw-r--r--src/pkg/net/http/transport.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/pkg/net/http/transport.go b/src/pkg/net/http/transport.go
index ea02ffb53..c14ee3aa6 100644
--- a/src/pkg/net/http/transport.go
+++ b/src/pkg/net/http/transport.go
@@ -715,7 +715,10 @@ func (pc *persistConn) readLoop() {
resp.Body = &bodyEOFSignal{body: resp.Body}
}
- if err != nil || resp.Close || rc.req.Close {
+ if err != nil || resp.Close || rc.req.Close || resp.StatusCode <= 199 {
+ // Don't do keep-alive on error if either party requested a close
+ // or we get an unexpected informational (1xx) response.
+ // StatusCode 100 is already handled above.
alive = false
}