Fix Stream() to use http.Request.Context

I found this when doing test with httptest, it doesnot support CloseNotify at all.
This commit is contained in:
Tiger Xu / Zhonghu Xu 2025-07-26 18:15:47 +08:00 committed by GitHub
parent dab5944a7b
commit 7525086d61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1242,7 +1242,7 @@ func (c *Context) SSEvent(name string, message any) {
// indicates "Is client disconnected in middle of stream" // indicates "Is client disconnected in middle of stream"
func (c *Context) Stream(step func(w io.Writer) bool) bool { func (c *Context) Stream(step func(w io.Writer) bool) bool {
w := c.Writer w := c.Writer
clientGone := w.CloseNotify() clientGone := c.Request.Context().Done()
for { for {
select { select {
case <-clientGone: case <-clientGone: