MCPcopy
hub / github.com/fastify/fastify / writeChunk

Function writeChunk

lib/reply.js:707–725  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

705 let offset = 0
706
707 function writeChunk () {
708 while (offset < buffer.length) {
709 /* c8 ignore next 3 - defensive guard for aborted responses */
710 if (res.destroyed || res.writableEnded) {
711 return
712 }
713
714 const end = Math.min(offset + HTTP2_WRITE_CHUNK_SIZE, buffer.length)
715 const shouldContinue = res.write(buffer.subarray(offset, end))
716 offset = end
717
718 if (shouldContinue === false) {
719 res.once('drain', writeChunk)
720 return
721 }
722 }
723
724 done()
725 }
726
727 writeChunk()
728}

Callers 1

writeHttp2PayloadFunction · 0.85

Calls 2

writeMethod · 0.80
doneFunction · 0.50

Tested by

no test coverage detected