From 126dda09258188e18a7d5f0736a6fb2b54f0c6ca Mon Sep 17 00:00:00 2001 From: Carlos Barcenilla Date: Wed, 11 Dec 2024 16:33:52 +0100 Subject: [PATCH] fix --- .../wsl-helper/pkg/dockerproxy/util/reverse_proxy.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/go/wsl-helper/pkg/dockerproxy/util/reverse_proxy.go b/src/go/wsl-helper/pkg/dockerproxy/util/reverse_proxy.go index 9fd361e749c..2009b2c744a 100644 --- a/src/go/wsl-helper/pkg/dockerproxy/util/reverse_proxy.go +++ b/src/go/wsl-helper/pkg/dockerproxy/util/reverse_proxy.go @@ -178,14 +178,19 @@ func (proxy *ReverseProxy) forwardRequest(w http.ResponseWriter, r *http.Request // - Manages buffered data // - Enables bidirectional communication after protocol upgrade func (*ReverseProxy) handleUpgradedConnection(w http.ResponseWriter, backendConn net.Conn) { - // Create a ResponseController to safely hijack the connection - rc := http.NewResponseController(w) + + // Cast writer to safely hijack the connection + hijacker, ok := w.(http.Hijacker) + if !ok { + http.Error(w, "client response writer does not support http.Hijacker", http.StatusInternalServerError) + return + } // Hijack attempts to take control of the underlying connection // Returns: // - clientConn: The raw network connection // - bufferedClientConn: A buffered reader/writer for any pending data - clientConn, bufferedClientConn, err := rc.Hijack() + clientConn, bufferedClientConn, err := hijacker.Hijack() if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return