From f898fb3fb823ec283f7ba05111d9fb0f5173a2d6 Mon Sep 17 00:00:00 2001 From: Nicholas Ciechanowski Date: Tue, 17 Dec 2024 03:48:56 +0000 Subject: [PATCH] fix: websockets breaking --- cache.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cache.go b/cache.go index 73bf8b0..3e71927 100644 --- a/cache.go +++ b/cache.go @@ -2,10 +2,13 @@ package plugin_simplecache import ( + "bufio" "context" "encoding/json" "errors" + "fmt" "log" + "net" "net/http" "time" @@ -169,3 +172,18 @@ func (rw *responseWriter) WriteHeader(s int) { rw.status = s rw.ResponseWriter.WriteHeader(s) } + +func (rw *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { + hijacker, ok := rw.ResponseWriter.(http.Hijacker) + if !ok { + return nil, nil, fmt.Errorf("%T is not a http.Hijacker", rw.ResponseWriter) + } + + return hijacker.Hijack() +} + +func (rw *responseWriter) Flush() { + if flusher, ok := rw.ResponseWriter.(http.Flusher); ok { + flusher.Flush() + } +}