From 26a190b5d1208f0ce099373ff49137d1910e6dd2 Mon Sep 17 00:00:00 2001 From: Zakir Jiwani <108548454+JiwaniZakir@users.noreply.github.com> Date: Tue, 17 Mar 2026 04:15:45 +0000 Subject: [PATCH] fix: replace deprecated http.CloseNotifier with Request.Context().Done() --- context.go | 2 +- response_writer.go | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/context.go b/context.go index 5174033e..1d0a1f49 100644 --- a/context.go +++ b/context.go @@ -1327,7 +1327,7 @@ func (c *Context) SSEvent(name string, message any) { // indicates "Is client disconnected in middle of stream" func (c *Context) Stream(step func(w io.Writer) bool) bool { w := c.Writer - clientGone := w.CloseNotify() + clientGone := c.Request.Context().Done() for { select { case <-clientGone: diff --git a/response_writer.go b/response_writer.go index 9035e6f1..9b2c4614 100644 --- a/response_writer.go +++ b/response_writer.go @@ -24,7 +24,6 @@ type ResponseWriter interface { http.ResponseWriter http.Hijacker http.Flusher - http.CloseNotifier // Status returns the HTTP response status code of the current request. Status() int @@ -120,11 +119,6 @@ func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { return w.ResponseWriter.(http.Hijacker).Hijack() } -// CloseNotify implements the http.CloseNotifier interface. -func (w *responseWriter) CloseNotify() <-chan bool { - return w.ResponseWriter.(http.CloseNotifier).CloseNotify() -} - // Flush implements the http.Flusher interface. func (w *responseWriter) Flush() { w.WriteHeaderNow()