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

Method onBody

deps/undici/undici.js:7541–7564  ·  view source on GitHub ↗

* @param {Buffer} buf * @returns {number}

(buf)

Source from the content-addressed store, hash-verified

7539 * @returns {number}
7540 */
7541 onBody(buf) {
7542 const { client, socket, statusCode, maxResponseSize } = this;
7543 if (socket.destroyed) {
7544 return -1;
7545 }
7546 const request = client[kQueue][client[kRunningIdx]];
7547 assert(request);
7548 assert(this.timeoutType === TIMEOUT_BODY);
7549 if (this.timeout) {
7550 if (this.timeout.refresh) {
7551 this.timeout.refresh();
7552 }
7553 }
7554 assert(statusCode >= 200);
7555 if (maxResponseSize > -1 && this.bytesRead + buf.length > maxResponseSize) {
7556 util.destroy(socket, new ResponseExceededMaxSizeError());
7557 return -1;
7558 }
7559 this.bytesRead += buf.length;
7560 if (request.onResponseData(buf) === false) {
7561 return constants.ERROR.PAUSED;
7562 }
7563 return 0;
7564 }
7565 /**
7566 * @returns {number}
7567 */

Callers 1

lazyllhttpFunction · 0.45

Calls 4

onResponseDataMethod · 0.65
assertFunction · 0.50
refreshMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected