Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bcxpro committed Dec 11, 2024
1 parent 139becb commit 126dda0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/go/wsl-helper/pkg/dockerproxy/util/reverse_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Check failure on line 180 in src/go/wsl-helper/pkg/dockerproxy/util/reverse_proxy.go

View workflow job for this annotation

GitHub Actions / test

unnecessary leading newline (whitespace)

Check failure on line 180 in src/go/wsl-helper/pkg/dockerproxy/util/reverse_proxy.go

View workflow job for this annotation

GitHub Actions / lint (macos-latest)

unnecessary leading newline (whitespace)
// 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
Expand Down

0 comments on commit 126dda0

Please sign in to comment.