]> Cypherpunks repositories - gostls13.git/commit
net/http: relax recently-updated rules and behavior of CloseNotifier
authorBrad Fitzpatrick <bradfitz@golang.org>
Mon, 4 Jan 2016 20:38:20 +0000 (20:38 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 5 Jan 2016 04:39:11 +0000 (04:39 +0000)
commit4b0bc7c3a14ac446bc13d22098de8db382205401
treebb2b2639674f6de7230d3116aaf5296c56b24d66
parent66f1f89dc058e98d4b118041cd8d571a505b43db
net/http: relax recently-updated rules and behavior of CloseNotifier

The CloseNotifier implementation and documentation was
substantially changed in https://golang.org/cl/17750 but it was a bit
too aggressive.

Issue #13666 highlighted that in addition to breaking external
projects, even the standard library (httputil.ReverseProxy) didn't
obey the new rules about not using CloseNotifier until the
Request.Body is fully consumed.

So, instead of fixing httputil.ReverseProxy, dial back the rules a
bit. It's now okay to call CloseNotify before consuming the request
body. The docs now say CloseNotifier may wait to fire before the
request body is fully consumed, but doesn't say that the behavior is
undefined anymore. Instead, we just wait until the request body is
consumed and start watching for EOF from the client then.

This CL also adds a test to ReverseProxy (using a POST request) that
would've caught this earlier.

Fixes #13666

Change-Id: Ib4e8c29c4bfbe7511f591cf9ffcda23a0f0b1269
Reviewed-on: https://go-review.googlesource.com/18144
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
src/net/http/httputil/reverseproxy_test.go
src/net/http/request.go
src/net/http/serve_test.go
src/net/http/server.go
src/net/http/transfer.go