aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/httputil/reverseproxy_test.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2018-01-05 21:35:51 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2018-01-06 01:14:49 +0000
commit24df1d06bc1544f096c484b30d50914f9d1d7c81 (patch)
tree443799feecfe29ae75228d462ac6c4479f411094 /src/net/http/httputil/reverseproxy_test.go
parent91f99852f638c249007a5a80277f75aa7cc9e0e8 (diff)
downloadgo-24df1d06bc1544f096c484b30d50914f9d1d7c81.tar.gz
go-24df1d06bc1544f096c484b30d50914f9d1d7c81.zip
Revert "net/http/httputil: allow ReverseProxy to call ModifyResponse on failed requests"
This reverts commit https://golang.org/cl/54030 Reason for revert: to not paint ourselves into a corner. See https://github.com/golang/go/issues/23009 Fixes #23009 Updates #21255 Change-Id: I68caab078839b9d2bf645a7bbed8405a5a30cd22 Reviewed-on: https://go-review.googlesource.com/86435 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/net/http/httputil/reverseproxy_test.go')
-rw-r--r--src/net/http/httputil/reverseproxy_test.go29
1 files changed, 0 insertions, 29 deletions
diff --git a/src/net/http/httputil/reverseproxy_test.go b/src/net/http/httputil/reverseproxy_test.go
index 822828e5c0..2232042d3e 100644
--- a/src/net/http/httputil/reverseproxy_test.go
+++ b/src/net/http/httputil/reverseproxy_test.go
@@ -631,35 +631,6 @@ func TestReverseProxyModifyResponse(t *testing.T) {
}
}
-// Issue 21255. Test ModifyResponse when an error from transport.RoundTrip
-// occurs, and that the proxy returns StatusOK.
-func TestReverseProxyModifyResponse_OnError(t *testing.T) {
- // Always returns an error
- errBackend := httptest.NewUnstartedServer(nil)
- errBackend.Config.ErrorLog = log.New(ioutil.Discard, "", 0) // quiet for tests
- defer errBackend.Close()
-
- rpURL, _ := url.Parse(errBackend.URL)
- rproxy := NewSingleHostReverseProxy(rpURL)
- rproxy.ModifyResponse = func(resp *http.Response) error {
- // Will be set for a non-nil error
- resp.StatusCode = http.StatusOK
- return nil
- }
-
- frontend := httptest.NewServer(rproxy)
- defer frontend.Close()
-
- resp, err := http.Get(frontend.URL)
- if err != nil {
- t.Fatalf("failed to reach proxy: %v", err)
- }
- if resp.StatusCode != http.StatusOK {
- t.Errorf("err != nil: got res.StatusCode %d; expected %d", resp.StatusCode, http.StatusOK)
- }
- resp.Body.Close()
-}
-
// Issue 16659: log errors from short read
func TestReverseProxy_CopyBuffer(t *testing.T) {
backendServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {