MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / sendContinuousChangesByHTTP

Method sendContinuousChangesByHTTP

rest/changes_api.go:485–512  ·  view source on GitHub ↗
(inChannels base.Set, options db.ChangesOptions)

Source from the content-addressed store, hash-verified

483}
484
485func (h *handler) sendContinuousChangesByHTTP(inChannels base.Set, options db.ChangesOptions) (error, bool) {
486 // Setting a non-default content type will keep the client HTTP framework from trying to sniff
487 // a real content-type from the response text, which can delay or prevent the client app from
488 // receiving the response.
489 h.setHeader("Content-Type", "application/octet-stream")
490 h.setHeader("Cache-Control", "private, max-age=0, no-cache, no-store")
491 h.logStatus(http.StatusOK, "sending continuous feed")
492 return h.generateContinuousChanges(inChannels, options, func(changes []*db.ChangeEntry) error {
493 var err error
494 if changes != nil {
495 for _, change := range changes {
496 data, _ := base.JSONMarshal(change)
497 if _, err = h.response.Write(data); err != nil {
498 break
499 }
500 if _, err = h.response.Write([]byte("\n")); err != nil {
501 break
502 }
503
504 change.AuditReadEvent(h.ctx())
505 }
506 } else {
507 _, err = h.response.Write([]byte("\n"))
508 }
509 h.flush()
510 return err
511 })
512}
513
514func (h *handler) sendContinuousChangesByWebSocket(inChannels base.Set, options db.ChangesOptions) (error, bool) {
515

Callers 1

handleChangesMethod · 0.95

Calls 8

setHeaderMethod · 0.95
logStatusMethod · 0.95
ctxMethod · 0.95
flushMethod · 0.95
JSONMarshalFunction · 0.92
AuditReadEventMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected