(payload, res, done)
| 715 | } |
| 716 | |
| 717 | function writeHttp2Payload (payload, res, done) { |
| 718 | const buffer = Buffer.isBuffer(payload) ? payload : Buffer.from(payload) |
| 719 | let offset = 0 |
| 720 | |
| 721 | function writeChunk () { |
| 722 | while (offset < buffer.length) { |
| 723 | /* c8 ignore next 3 - defensive guard for aborted responses */ |
| 724 | if (res.destroyed || res.writableEnded) { |
| 725 | return |
| 726 | } |
| 727 | |
| 728 | const end = Math.min(offset + HTTP2_WRITE_CHUNK_SIZE, buffer.length) |
| 729 | const shouldContinue = res.write(buffer.subarray(offset, end)) |
| 730 | offset = end |
| 731 | |
| 732 | if (shouldContinue === false) { |
| 733 | res.once('drain', writeChunk) |
| 734 | return |
| 735 | } |
| 736 | } |
| 737 | |
| 738 | done() |
| 739 | } |
| 740 | |
| 741 | writeChunk() |
| 742 | } |
| 743 | |
| 744 | function logStreamError (err, reply, res) { |
| 745 | reply.server[kLogController].streamError(err, reply.request, reply) |
no test coverage detected