(abort, body, client, request, socket, contentLength, header, expectsPayload)
| 6825 | } |
| 6826 | }; |
| 6827 | body.on("data", onData).on("end", onFinished).on("error", onFinished).on("close", onClose); |
| 6828 | if (body.resume) { |
| 6829 | body.resume(); |
| 6830 | } |
| 6831 | socket.on("drain", onDrain).on("error", onFinished); |
| 6832 | if ((_a = body.errorEmitted) != null ? _a : body.errored) { |
| 6833 | setImmediate(() => onFinished(body.errored)); |
| 6834 | } else if ((_b = body.endEmitted) != null ? _b : body.readableEnded) { |
| 6835 | setImmediate(() => onFinished(null)); |
| 6836 | } |
| 6837 | if ((_c = body.closeEmitted) != null ? _c : body.closed) { |
| 6838 | setImmediate(onClose); |
| 6839 | } |
| 6840 | } |
| 6841 | function writeBuffer(abort, body, client, request, socket, contentLength, header, expectsPayload) { |
| 6842 | try { |
| 6843 | if (!body) { |
| 6844 | if (contentLength === 0) { |
| 6845 | socket.write(`${header}content-length: 0\r |
| 6846 | \r |
| 6847 | `, "latin1"); |
| 6848 | } else { |
| 6849 | assert(contentLength === null, "no body must not have content length"); |
| 6850 | socket.write(`${header}\r |
| 6851 | `, "latin1"); |
| 6852 | } |
| 6853 | } else if (util.isBuffer(body)) { |
| 6854 | assert(contentLength === body.byteLength, "buffer body must have content length"); |
| 6855 | socket.cork(); |
| 6856 | socket.write(`${header}content-length: ${contentLength}\r |
| 6857 | \r |
| 6858 | `, "latin1"); |
| 6859 | socket.write(body); |
| 6860 | socket.uncork(); |
no test coverage detected