fix: replace deprecated http.CloseNotifier with Request.Context().Done()

This commit is contained in:
Zakir Jiwani 2026-03-17 04:15:45 +00:00
parent d3ffc99852
commit 26a190b5d1
2 changed files with 1 additions and 7 deletions

View File

@ -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:

View File

@ -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()