* @returns {number}
()
| 7566 | * @returns {number} |
| 7567 | */ |
| 7568 | onMessageComplete() { |
| 7569 | const { client, socket, statusCode, upgrade, headers, contentLength, bytesRead, shouldKeepAlive } = this; |
| 7570 | if (socket.destroyed && (!statusCode || shouldKeepAlive)) { |
| 7571 | return -1; |
| 7572 | } |
| 7573 | if (upgrade) { |
| 7574 | return 0; |
| 7575 | } |
| 7576 | assert(statusCode >= 100); |
| 7577 | assert((this.headers.length & 1) === 0); |
| 7578 | const request = client[kQueue][client[kRunningIdx]]; |
| 7579 | assert(request); |
| 7580 | this.statusCode = 0; |
| 7581 | this.statusText = ""; |
| 7582 | this.bytesRead = 0; |
| 7583 | this.contentLength = -1; |
| 7584 | this.keepAlive = ""; |
| 7585 | this.connectionKeepAlive = false; |
| 7586 | this.headers = []; |
| 7587 | this.headersSize = 0; |
| 7588 | if (statusCode < 200) { |
| 7589 | return 0; |
| 7590 | } |
| 7591 | if (request.method !== "HEAD" && contentLength !== -1 && bytesRead !== contentLength) { |
| 7592 | util.destroy(socket, new ResponseContentLengthMismatchError()); |
| 7593 | return -1; |
| 7594 | } |
| 7595 | request.onResponseEnd(headers); |
| 7596 | client[kQueue][client[kRunningIdx]++] = null; |
| 7597 | socket[kSocketUsed] = client[kPending] === 0; |
| 7598 | if (socket[kWriting]) { |
| 7599 | assert(client[kRunning] === 0); |
| 7600 | util.destroy(socket, new InformationalError("reset")); |
| 7601 | return constants.ERROR.PAUSED; |
| 7602 | } else if (!shouldKeepAlive) { |
| 7603 | util.destroy(socket, new InformationalError("reset")); |
| 7604 | return constants.ERROR.PAUSED; |
| 7605 | } else if (socket[kReset] && client[kRunning] === 0) { |
| 7606 | util.destroy(socket, new InformationalError("reset")); |
| 7607 | return constants.ERROR.PAUSED; |
| 7608 | } else if (client[kPipelining] == null || client[kPipelining] === 1) { |
| 7609 | setImmediate(client[kResume]); |
| 7610 | } else { |
| 7611 | client[kResume](); |
| 7612 | } |
| 7613 | return 0; |
| 7614 | } |
| 7615 | }; |
| 7616 | function onParserTimeout(parserWeakRef) { |
| 7617 | const parser = parserWeakRef.deref(); |
no test coverage detected