(abort, body, client, request, socket, contentLength, header, expectsPayload)
| 6825 | } |
| 6826 | } |
| 6827 | function writeBuffer(abort, body, client, request, socket, contentLength, header, expectsPayload) { |
| 6828 | try { |
| 6829 | if (!body) { |
| 6830 | if (contentLength === 0) { |
| 6831 | socket.write(`${header}content-length: 0\r |
| 6832 | \r |
| 6833 | `, "latin1"); |
| 6834 | } else { |
| 6835 | assert(contentLength === null, "no body must not have content length"); |
| 6836 | socket.write(`${header}\r |
| 6837 | `, "latin1"); |
| 6838 | } |
| 6839 | } else if (util.isBuffer(body)) { |
| 6840 | assert(contentLength === body.byteLength, "buffer body must have content length"); |
| 6841 | socket.cork(); |
| 6842 | socket.write(`${header}content-length: ${contentLength}\r |
| 6843 | \r |
| 6844 | `, "latin1"); |
| 6845 | socket.write(body); |
| 6846 | socket.uncork(); |
| 6847 | request.onBodySent(body); |
| 6848 | if (!expectsPayload && request.reset !== false) { |
| 6849 | socket[kReset] = true; |
| 6850 | } |
| 6851 | } |
| 6852 | request.onRequestSent(); |
| 6853 | client[kResume](); |
| 6854 | } catch (err) { |
| 6855 | abort(err); |
| 6856 | } |
| 6857 | } |
| 6858 | function writeBlob(abort, body, client, request, socket, contentLength, header, expectsPayload) { |
| 6859 | return __async(this, null, function* () { |
| 6860 | assert(contentLength === body.size, "blob body must have content length"); |
no test coverage detected