| 6103 | var currentBufferSize = 0; |
| 6104 | var currentBufferPtr = null; |
| 6105 | var USE_NATIVE_TIMER = 0; |
| 6106 | var USE_FAST_TIMER = 1; |
| 6107 | var TIMEOUT_HEADERS = 2 | USE_FAST_TIMER; |
| 6108 | var TIMEOUT_BODY = 4 | USE_FAST_TIMER; |
| 6109 | var TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER; |
| 6110 | var Parser = class { |
| 6111 | constructor(client, socket, { exports: exports2 }) { |
| 6112 | assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0); |
| 6113 | this.llhttp = exports2; |
| 6114 | this.ptr = this.llhttp.llhttp_alloc(constants3.TYPE.RESPONSE); |
| 6115 | this.client = client; |
| 6116 | this.socket = socket; |
| 6117 | this.timeout = null; |
| 6118 | this.timeoutValue = null; |
| 6119 | this.timeoutType = null; |
| 6120 | this.statusCode = null; |
| 6121 | this.statusText = ""; |
| 6122 | this.upgrade = false; |
| 6123 | this.headers = []; |
| 6124 | this.headersSize = 0; |
| 6125 | this.headersMaxSize = client[kMaxHeadersSize]; |
| 6126 | this.shouldKeepAlive = false; |
| 6127 | this.paused = false; |
| 6128 | this.resume = this.resume.bind(this); |
| 6129 | this.bytesRead = 0; |
| 6130 | this.keepAlive = ""; |
| 6131 | this.contentLength = ""; |
| 6132 | this.connection = ""; |
| 6133 | this.maxResponseSize = client[kMaxResponseSize]; |
| 6134 | } |
| 6135 | setTimeout(delay, type) { |
| 6136 | if (delay !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) { |
| 6137 | if (this.timeout) { |
| 6138 | timers.clearTimeout(this.timeout); |
| 6139 | this.timeout = null; |
| 6140 | } |
| 6141 | if (delay) { |
| 6142 | if (type & USE_FAST_TIMER) { |
| 6143 | this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this)); |
| 6144 | } else { |
| 6145 | this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this)); |
| 6146 | this.timeout.unref(); |
| 6147 | } |
| 6148 | } |