]> Cypherpunks repositories - gostls13.git/commit
net/http/httputil: make ReverseProxy send nil Body requests when possible
authorBrad Fitzpatrick <bradfitz@golang.org>
Fri, 2 Sep 2016 05:00:05 +0000 (05:00 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 2 Sep 2016 23:57:58 +0000 (23:57 +0000)
commit7cbc1058ea9240d9df92a339932d5c6dce694e7a
treec7c8e260a0259d0e144b1b73df92a924586b1aae
parent0b84a64da173d811d01a8a59545c22a7e1fd986a
net/http/httputil: make ReverseProxy send nil Body requests when possible

The http.Transport's retry can't retry requests with non-nil
bodies. When cloning an incoming server request into an outgoing
client request, nil out the Body field if the ContentLength is 0. (For
server requests, Body is always non-nil, even for GET, HEAD, etc.)

Also, don't use the deprecated CancelRequest and use Context instead.

And don't set Proto, ProtoMajor, ProtoMinor. Those are ignored in
client requests, which was probably a later documentation
clarification.

Fixes #16036
Updates #16696 (remove useless Proto lines)

Change-Id: I70a869e9bd4bf240c5838e82fb5aa695a539b343
Reviewed-on: https://go-review.googlesource.com/28412
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
src/go/build/deps_test.go
src/net/http/httputil/reverseproxy.go
src/net/http/httputil/reverseproxy_test.go