Makefile,internal: fix websocket regression and other small things (#830)

- fix websocket regression and add test to prevent in the future
- fix staticheck errors
- remove proxy package remnants from Makefile 

fix #829
This commit is contained in:
Benson Wong
2026-06-09 21:37:53 -07:00
committed by GitHub
parent 44e1501e81
commit 0cfe5a6639
7 changed files with 200 additions and 21 deletions
+12 -1
View File
@@ -1,6 +1,7 @@
package server
import (
"bufio"
"context"
"fmt"
"io"
@@ -150,7 +151,8 @@ var requestLogPathSkips = []string{"/wol-health", "/api/performance", "/metrics"
// statusRecorder wraps an http.ResponseWriter to capture the response status
// code and the number of body bytes written, so the access log can report
// them. Flush is forwarded so streaming handlers (SSE) still work.
// them. Flush is forwarded so streaming handlers (SSE) still work, and Hijack
// is forwarded so httputil.ReverseProxy can upgrade websocket connections.
type statusRecorder struct {
http.ResponseWriter
status int
@@ -174,6 +176,15 @@ func (sr *statusRecorder) Flush() {
}
}
// Hijack forwards to the underlying ResponseWriter so httputil.ReverseProxy can
// take over the connection for websocket upgrades.
func (sr *statusRecorder) Hijack() (net.Conn, *bufio.ReadWriter, error) {
if hj, ok := sr.ResponseWriter.(http.Hijacker); ok {
return hj.Hijack()
}
return nil, nil, fmt.Errorf("underlying ResponseWriter does not support hijacking")
}
// clientIP resolves the originating client address, preferring proxy headers
// over the raw connection address.
func clientIP(r *http.Request) string {