| 6483 | } |
| 6484 | __name(writeIterable, "writeIterable"); |
| 6485 | var _AsyncWriter = class _AsyncWriter { |
| 6486 | constructor({ abort, socket, request, contentLength, client, expectsPayload, header }) { |
| 6487 | this.socket = socket; |
| 6488 | this.request = request; |
| 6489 | this.contentLength = contentLength; |
| 6490 | this.client = client; |
| 6491 | this.bytesWritten = 0; |
| 6492 | this.expectsPayload = expectsPayload; |
| 6493 | this.header = header; |
| 6494 | this.abort = abort; |
| 6495 | socket[kWriting] = true; |
| 6496 | } |
| 6497 | write(chunk) { |
| 6498 | const { socket, request, contentLength, client, bytesWritten, expectsPayload, header } = this; |
| 6499 | if (socket[kError]) { |
| 6500 | throw socket[kError]; |
| 6501 | } |
| 6502 | if (socket.destroyed) { |
| 6503 | return false; |
| 6504 | } |
| 6505 | const len = Buffer.byteLength(chunk); |
| 6506 | if (!len) { |
| 6507 | return true; |
| 6508 | } |
| 6509 | if (contentLength !== null && bytesWritten + len > contentLength) { |
| 6510 | if (client[kStrictContentLength]) { |
| 6511 | throw new RequestContentLengthMismatchError(); |
| 6512 | } |
| 6513 | define_process_default.emitWarning(new RequestContentLengthMismatchError()); |
| 6514 | } |
| 6515 | socket.cork(); |
| 6516 | if (bytesWritten === 0) { |
| 6517 | if (!expectsPayload && request.reset !== false) { |
| 6518 | socket[kReset] = true; |
| 6519 | } |
| 6520 | if (contentLength === null) { |
| 6521 | socket.write(`${header}transfer-encoding: chunked\r |
| 6522 | `, "latin1"); |
| 6523 | } else { |
| 6524 | socket.write(`${header}content-length: ${contentLength}\r |
| 6525 | \r |
| 6526 | `, "latin1"); |
| 6527 | } |
| 6528 | } |
| 6529 | if (contentLength === null) { |
| 6530 | socket.write(`\r |
| 6531 | ${len.toString(16)}\r |
| 6532 | `, "latin1"); |
| 6533 | } |
| 6534 | this.bytesWritten += len; |
| 6535 | const ret = socket.write(chunk); |
| 6536 | socket.uncork(); |
| 6537 | request.onBodySent(chunk); |
| 6538 | if (!ret) { |
| 6539 | if (socket[kParser].timeout && socket[kParser].timeoutType === TIMEOUT_HEADERS) { |
| 6540 | if (socket[kParser].timeout.refresh) { |
| 6541 | socket[kParser].timeout.refresh(); |
| 6542 | } |
nothing calls this directly
no outgoing calls
no test coverage detected