| 6165 | return this.createError(ret, EMPTY_BUF); |
| 6166 | } |
| 6167 | createError(ret, data) { |
| 6168 | const { llhttp, contentLength, bytesRead } = this; |
| 6169 | if (contentLength && bytesRead !== parseInt(contentLength, 10)) { |
| 6170 | return new ResponseContentLengthMismatchError(); |
| 6171 | } |
| 6172 | const ptr = llhttp.llhttp_get_error_reason(this.ptr); |
| 6173 | let message = ""; |
| 6174 | if (ptr) { |
| 6175 | const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0); |
| 6176 | message = "Response does not match the HTTP/1.1 protocol (" + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ")"; |
| 6177 | } |
| 6178 | return new HTTPParserError(message, constants3.ERROR[ret], data); |
| 6179 | } |
| 6180 | destroy() { |
| 6181 | assert(this.ptr != null); |
| 6182 | assert(currentParser == null); |