(chunk)
| 6943 | socket[kWriting] = true; |
| 6944 | } |
| 6945 | write(chunk) { |
| 6946 | const { socket, request, contentLength, client, bytesWritten, expectsPayload, header } = this; |
| 6947 | if (socket[kError]) { |
| 6948 | throw socket[kError]; |
| 6949 | } |
| 6950 | if (socket.destroyed) { |
| 6951 | return false; |
| 6952 | } |
| 6953 | const len = Buffer.byteLength(chunk); |
| 6954 | if (!len) { |
| 6955 | return true; |
| 6956 | } |
| 6957 | if (contentLength !== null && bytesWritten + len > contentLength) { |
| 6958 | if (client[kStrictContentLength]) { |
| 6959 | throw new RequestContentLengthMismatchError(); |
| 6960 | } |
| 6961 | process.emitWarning(new RequestContentLengthMismatchError()); |
| 6962 | } |
| 6963 | socket.cork(); |
| 6964 | if (bytesWritten === 0) { |
| 6965 | if (!expectsPayload && request.reset !== false) { |
| 6966 | socket[kReset] = true; |
| 6967 | } |
| 6968 | if (contentLength === null) { |
| 6969 | socket.write(`${header}transfer-encoding: chunked\r |
| 6970 | `, "latin1"); |
| 6971 | } else { |
| 6972 | socket.write(`${header}content-length: ${contentLength}\r |
| 6973 | \r |
| 6974 | `, "latin1"); |
| 6975 | } |
| 6976 | } |
| 6977 | if (contentLength === null) { |
| 6978 | socket.write(`\r |
| 6979 | ${len.toString(16)}\r |
| 6980 | `, "latin1"); |
| 6981 | } |
| 6982 | this.bytesWritten += len; |
| 6983 | const ret = socket.write(chunk); |
| 6984 | socket.uncork(); |
| 6985 | request.onBodySent(chunk); |
| 6986 | if (!ret) { |
| 6987 | if (socket[kParser].timeout && socket[kParser].timeoutType === TIMEOUT_HEADERS) { |
| 6988 | if (socket[kParser].timeout.refresh) { |
| 6989 | socket[kParser].timeout.refresh(); |
| 6990 | } |
| 6991 | } |
| 6992 | } |
| 6993 | return ret; |
| 6994 | } |
| 6995 | end() { |
| 6996 | const { socket, contentLength, client, bytesWritten, expectsPayload, header, request } = this; |
| 6997 | request.onRequestSent(); |
no test coverage detected