()
| 6993 | ${len.toString(16)}\r |
| 6994 | `, "latin1"); |
| 6995 | } |
| 6996 | this.bytesWritten += len; |
| 6997 | const ret = socket.write(chunk); |
| 6998 | socket.uncork(); |
| 6999 | request.onBodySent(chunk); |
| 7000 | if (!ret) { |
| 7001 | if (socket[kParser].timeout && socket[kParser].timeoutType === TIMEOUT_HEADERS) { |
| 7002 | if (socket[kParser].timeout.refresh) { |
| 7003 | socket[kParser].timeout.refresh(); |
| 7004 | } |
| 7005 | } |
| 7006 | } |
| 7007 | return ret; |
| 7008 | } |
| 7009 | end() { |
| 7010 | const { socket, contentLength, client, bytesWritten, expectsPayload, header, request } = this; |
| 7011 | request.onRequestSent(); |
| 7012 | socket[kWriting] = false; |
| 7013 | if (socket[kError]) { |
| 7014 | throw socket[kError]; |
| 7015 | } |
| 7016 | if (socket.destroyed) { |
| 7017 | return; |
| 7018 | } |
| 7019 | if (bytesWritten === 0) { |
| 7020 | if (expectsPayload) { |
| 7021 | socket.write(`${header}content-length: 0\r |
| 7022 | \r |
| 7023 | `, "latin1"); |
| 7024 | } else { |
| 7025 | socket.write(`${header}\r |
| 7026 | `, "latin1"); |
| 7027 | } |
| 7028 | } else if (contentLength === null) { |
| 7029 | socket.write("\r\n0\r\n\r\n", "latin1"); |
| 7030 | } |
| 7031 | if (contentLength !== null && bytesWritten !== contentLength) { |
| 7032 | if (client[kStrictContentLength]) { |
| 7033 | throw new RequestContentLengthMismatchError(); |
no test coverage detected