* @param {Buffer} buf * @returns {number}
(buf)
| 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 | */ |
no test coverage detected