MCPcopy
hub / github.com/gin-gonic/gin / Stream

Method Stream

context.go:1322–1337  ·  view source on GitHub ↗

Stream sends a streaming response and returns a boolean indicates "Is client disconnected in middle of stream"

(step func(w io.Writer) bool)

Source from the content-addressed store, hash-verified

1320// Stream sends a streaming response and returns a boolean
1321// indicates "Is client disconnected in middle of stream"
1322func (c *Context) Stream(step func(w io.Writer) bool) bool {
1323 w := c.Writer
1324 clientGone := w.CloseNotify()
1325 for {
1326 select {
1327 case <-clientGone:
1328 return true
1329 default:
1330 keepOpen := step(w)
1331 w.Flush()
1332 if !keepOpen {
1333 return false
1334 }
1335 }
1336 }
1337}
1338
1339/************************************/
1340/******** CONTENT NEGOTIATION *******/

Callers 2

TestContextStreamFunction · 0.80

Calls 2

FlushMethod · 0.80
CloseNotifyMethod · 0.45

Tested by 2

TestContextStreamFunction · 0.64