mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-14 20:22:20 +08:00
fix(context): improve client disconnection handling in Stream method
This commit is contained in:
parent
49e9137c68
commit
b0e3cdc077
@ -1208,7 +1208,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:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user