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

Method writeRawJSONWithoutClientVerification

rest/handler.go:1518–1534  ·  view source on GitHub ↗

Do not call from HTTP handlers. Use h.writeRawJSON/h.writeRawJSONStatus instead. writeRawJSONWithoutClientVerification takes the given bytes and always writes the response as JSON, without checking that the client can accept it.

(status int, b []byte)

Source from the content-addressed store, hash-verified

1516// writeRawJSONWithoutClientVerification takes the given bytes and always writes the response as JSON,
1517// without checking that the client can accept it.
1518func (h *handler) writeRawJSONWithoutClientVerification(status int, b []byte) {
1519 if h.rq.Method != "HEAD" {
1520 h.setHeader("Content-Type", "application/json")
1521 if len(b) < minCompressibleJSONSize {
1522 h.disableResponseCompression()
1523 }
1524 h.setHeader("Content-Length", fmt.Sprintf("%d", len(b)))
1525 if status > 0 {
1526 h.response.WriteHeader(status)
1527 h.setStatus(status, "")
1528 }
1529 _, _ = h.response.Write(b)
1530 } else if status > 0 {
1531 h.response.WriteHeader(status)
1532 h.setStatus(status, "")
1533 }
1534}
1535
1536// writeJSON writes the given value as a JSON response with a 200 OK status.
1537func (h *handler) writeJSON(value interface{}) {

Callers 2

writeJSONStatusMethod · 0.95
writeRawJSONStatusMethod · 0.95

Calls 5

setHeaderMethod · 0.95
setStatusMethod · 0.95
WriteHeaderMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected