Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: preserve Hijacker/Flusher on statusWriter

Mario12b6b74ee738
diff --git a/middleware.go b/middleware.go
index ee5c4949..94ca84be 100644
--- a/middleware.go
+++ b/middleware.go
@@ -1,15 +1,18 @@
package main
import (
+ "bufio"
"context"
"encoding/json"
"fmt"
"log/slog"
+ "net"
"net/http"
"time"
)
// statusWriter wraps ResponseWriter to capture the status code.
+// It preserves Hijacker and Flusher interfaces for WebSocket/SSE support.
type statusWriter struct {
http.ResponseWriter
code int
@@ -20,6 +23,19 @@ func (w *statusWriter) WriteHeader(code int) {
w.ResponseWriter.WriteHeader(code)
}
+func (w *statusWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
+ if h, ok := w.ResponseWriter.(http.Hijacker); ok {
+ return h.Hijack()
+ }
+ return nil, nil, fmt.Errorf("underlying ResponseWriter is not a Hijacker")
+}
+
+func (w *statusWriter) Flush() {
+ if f, ok := w.ResponseWriter.(http.Flusher); ok {
+ f.Flush()
+ }
+}
+
func loggingMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()