net/http/httputil: don't panic in ReverseProxy unless running under a Server

Prior to the fix to #23643, the ReverseProxy didn't panic with
ErrAbortHandler when the copy to a client failed.

During Go 1.11 beta testing, we found plenty of code using
ReverseProxy in tests that were unprepared for a panic.

Change the behavior to only panic when running under the http.Server
that'll handle the panic.

Updates #23643

Change-Id: Ic1fa8405fd54c858ce8c797cec79d006833a9f7d
Reviewed-on: https://go-review.googlesource.com/122819
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Brad Fitzpatrick 2018-07-09 22:29:00 +00:00
parent 5fbfda6a83
commit eab57b27f5
2 changed files with 28 additions and 1 deletions

View file

@ -29,6 +29,7 @@ import (
const fakeHopHeader = "X-Fake-Hop-Header-For-Test"
func init() {
inOurTests = true
hopHeaders = append(hopHeaders, fakeHopHeader)
}