From c91cb1c1469a7b43c197b1818999d42f95185cf6 Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Mon, 29 Apr 2019 14:52:11 -0400 Subject: [PATCH] Remove proxy workaround fixed in go 1.12.4 --- .../pkg/util/proxy/upgradeaware.go | 29 +------------------ 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/staging/src/k8s.io/apimachinery/pkg/util/proxy/upgradeaware.go b/staging/src/k8s.io/apimachinery/pkg/util/proxy/upgradeaware.go index c3591db40d4..3c8e09399f5 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/proxy/upgradeaware.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/proxy/upgradeaware.go @@ -230,34 +230,7 @@ func (h *UpgradeAwareHandler) ServeHTTP(w http.ResponseWriter, req *http.Request proxy := httputil.NewSingleHostReverseProxy(&url.URL{Scheme: h.Location.Scheme, Host: h.Location.Host}) proxy.Transport = h.Transport proxy.FlushInterval = h.FlushInterval - proxy.ServeHTTP(maybeWrapFlushHeadersWriter(w), newReq) -} - -// maybeWrapFlushHeadersWriter wraps the given writer to force flushing headers prior to writing the response body. -// if the given writer does not support http.Flusher, http.Hijacker, and http.CloseNotifier, the original writer is returned. -// TODO(liggitt): drop this once https://github.com/golang/go/issues/31125 is fixed -func maybeWrapFlushHeadersWriter(w http.ResponseWriter) http.ResponseWriter { - flusher, isFlusher := w.(http.Flusher) - hijacker, isHijacker := w.(http.Hijacker) - closeNotifier, isCloseNotifier := w.(http.CloseNotifier) - // flusher, hijacker, and closeNotifier are all used by the ReverseProxy implementation. - // if the given writer can't support all three, return the original writer. - if !isFlusher || !isHijacker || !isCloseNotifier { - return w - } - return &flushHeadersWriter{w, flusher, hijacker, closeNotifier} -} - -type flushHeadersWriter struct { - http.ResponseWriter - http.Flusher - http.Hijacker - http.CloseNotifier -} - -func (w *flushHeadersWriter) WriteHeader(code int) { - w.ResponseWriter.WriteHeader(code) - w.Flusher.Flush() + proxy.ServeHTTP(w, newReq) } // tryUpgrade returns true if the request was handled.