diff --git a/ingress/origin_service.go b/ingress/origin_service.go index 2bca701f..5d7cec32 100644 --- a/ingress/origin_service.go +++ b/ingress/origin_service.go @@ -4,6 +4,7 @@ import ( "context" "crypto/tls" "fmt" + "io" "net" "net/http" "net/url" @@ -252,8 +253,9 @@ func (o *statusCode) RoundTrip(_ *http.Request) (*http.Response, error) { type NopReadCloser struct{} +// Read always returns EOF to signal end of input func (nrc *NopReadCloser) Read(buf []byte) (int, error) { - return 0, nil + return 0, io.EOF } func (nrc *NopReadCloser) Close() error { diff --git a/ingress/rule_test.go b/ingress/rule_test.go index c42b1b65..f5bfcd92 100644 --- a/ingress/rule_test.go +++ b/ingress/rule_test.go @@ -1,6 +1,8 @@ package ingress import ( + "io" + "net/http/httptest" "net/url" "regexp" "testing" @@ -128,9 +130,16 @@ func TestStaticHTTPStatus(t *testing.T) { resp, err := o.RoundTrip(nil) require.NoError(t, err) _, err = resp.Body.Read(buf) - require.NoError(t, err) + require.Equal(t, io.EOF, err) require.NoError(t, resp.Body.Close()) require.Equal(t, 404, resp.StatusCode) + + resp, err = o.RoundTrip(nil) + require.NoError(t, err) + w := httptest.NewRecorder() + n, err := io.Copy(w, resp.Body) + require.NoError(t, err) + require.Equal(t, int64(0), n) } sendReq() sendReq()