mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
91f99852f6
commit
24df1d06bc
2 changed files with 8 additions and 42 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue