diff --git a/context.go b/context.go index 5174033eb3..1d0a1f4983 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 9035e6f1fd..9b2c46141a 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() diff --git a/response_writer_test.go b/response_writer_test.go index dfc1d2c60d..98d861bce8 100644 --- a/response_writer_test.go +++ b/response_writer_test.go @@ -17,7 +17,6 @@ import ( // TODO // func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { -// func (w *responseWriter) CloseNotify() <-chan bool { // func (w *responseWriter) Flush() { var ( @@ -26,7 +25,6 @@ var ( _ http.ResponseWriter = ResponseWriter(&responseWriter{}) _ http.Hijacker = ResponseWriter(&responseWriter{}) _ http.Flusher = ResponseWriter(&responseWriter{}) - _ http.CloseNotifier = ResponseWriter(&responseWriter{}) ) func init() { @@ -119,10 +117,6 @@ func TestResponseWriterHijack(t *testing.T) { }) assert.True(t, w.Written()) - assert.Panics(t, func() { - w.CloseNotify() - }) - w.Flush() }