MCPcopy Create free account
hub / github.com/nodejs/node / end

Method end

deps/undici/undici.js:8225–8260  ·  view source on GitHub ↗

* @returns {void}

()

Source from the content-addressed store, hash-verified

8223 * @returns {void}
8224 */
8225 end() {
8226 const { socket, contentLength, client, bytesWritten, expectsPayload, header, request } = this;
8227 request.onRequestSent();
8228 socket[kWriting] = false;
8229 if (socket[kError]) {
8230 throw socket[kError];
8231 }
8232 if (socket.destroyed) {
8233 return;
8234 }
8235 if (bytesWritten === 0) {
8236 if (expectsPayload) {
8237 socket.write(`${header}content-length: 0\r
8238\r
8239`, "latin1");
8240 } else {
8241 socket.write(`${header}\r
8242`, "latin1");
8243 }
8244 } else if (contentLength === null) {
8245 socket.write("\r\n0\r\n\r\n", "latin1");
8246 }
8247 if (contentLength !== null && bytesWritten !== contentLength) {
8248 if (client[kStrictContentLength]) {
8249 throw new RequestContentLengthMismatchError();
8250 } else {
8251 process.emitWarning(new RequestContentLengthMismatchError());
8252 }
8253 }
8254 if (socket[kParser].timeout && socket[kParser].timeoutType === TIMEOUT_HEADERS) {
8255 if (socket[kParser].timeout.refresh) {
8256 socket[kParser].timeout.refresh();
8257 }
8258 }
8259 client[kResume]();
8260 }
8261 /**
8262 * @param {Error} [err]
8263 * @returns {void}

Callers 5

_finalMethod · 0.45
writeBufferFunction · 0.45
writeBlobFunction · 0.45
writeIterableFunction · 0.45
onResponseEndMethod · 0.45

Calls 3

onRequestSentMethod · 0.65
writeMethod · 0.45
refreshMethod · 0.45

Tested by

no test coverage detected