From 2e6440fbebf4868169fb479de53a1d248694404f Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Fri, 26 Jul 2019 10:40:17 -0400 Subject: [PATCH] Avoid echoing request URL in proxy error --- staging/src/k8s.io/apimachinery/pkg/util/proxy/transport.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/apimachinery/pkg/util/proxy/transport.go b/staging/src/k8s.io/apimachinery/pkg/util/proxy/transport.go index 673a4df6b3d..aecafb35259 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/proxy/transport.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/proxy/transport.go @@ -101,11 +101,14 @@ func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { resp, err := rt.RoundTrip(req) if err != nil { - message := fmt.Sprintf("Error: '%s'\nTrying to reach: '%v'", err.Error(), req.URL.String()) + message := fmt.Sprintf("Error trying to reach service: '%v'", err.Error()) resp = &http.Response{ + Header: http.Header{}, StatusCode: http.StatusServiceUnavailable, Body: ioutil.NopCloser(strings.NewReader(message)), } + resp.Header.Set("Content-Type", "text/plain; charset=utf-8") + resp.Header.Set("X-Content-Type-Options", "nosniff") return resp, nil }