(abort, body, client, request, socket, contentLength, header, expectsPayload)
| 6825 | if (channels.sendHeaders.hasSubscribers) { |
| 6826 | channels.sendHeaders.publish({ request, headers: header, socket }); |
| 6827 | } |
| 6828 | if (!body || bodyLength === 0) { |
| 6829 | writeBuffer(abort, null, client, request, socket, contentLength, header, expectsPayload); |
| 6830 | } else if (util.isBuffer(body)) { |
| 6831 | writeBuffer(abort, body, client, request, socket, contentLength, header, expectsPayload); |
| 6832 | } else if (util.isBlobLike(body)) { |
| 6833 | if (typeof body.stream === "function") { |
| 6834 | writeIterable(abort, body.stream(), client, request, socket, contentLength, header, expectsPayload); |
| 6835 | } else { |
| 6836 | writeBlob(abort, body, client, request, socket, contentLength, header, expectsPayload); |
| 6837 | } |
| 6838 | } else if (util.isStream(body)) { |
| 6839 | writeStream(abort, body, client, request, socket, contentLength, header, expectsPayload); |
| 6840 | } else if (util.isIterable(body)) { |
| 6841 | writeIterable(abort, body, client, request, socket, contentLength, header, expectsPayload); |
| 6842 | } else { |
| 6843 | assert(false); |
| 6844 | } |
| 6845 | return true; |
| 6846 | } |
| 6847 | function writeStream(abort, body, client, request, socket, contentLength, header, expectsPayload) { |
| 6848 | var _a, _b, _c; |
| 6849 | assert(contentLength !== 0 || client[kRunning] === 0, "stream body cannot be pipelined"); |
| 6850 | let finished = false; |
| 6851 | const writer = new AsyncWriter({ abort, socket, request, contentLength, client, expectsPayload, header }); |
| 6852 | const onData = function(chunk) { |
| 6853 | if (finished) { |
| 6854 | return; |
| 6855 | } |
| 6856 | try { |
| 6857 | if (!writer.write(chunk) && this.pause) { |
| 6858 | this.pause(); |
| 6859 | } |
| 6860 | } catch (err) { |
no test coverage detected