@@ -5873,24 +5873,55 @@ var require_client_h1 = __commonJS({
58735873 currentBufferRef = null;
58745874 }
58755875 const offset = llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr;
5876- if (ret === constants3.ERROR.PAUSED_UPGRADE) {
5877- this.onUpgrade(data.slice(offset));
5878- } else if (ret === constants3.ERROR.PAUSED) {
5879- this.paused = true;
5880- socket.unshift(data.slice(offset));
5881- } else if (ret !== constants3.ERROR.OK) {
5882- const ptr = llhttp.llhttp_get_error_reason(this.ptr);
5883- let message = "";
5884- if (ptr) {
5885- const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0);
5886- message = "Response does not match the HTTP/1.1 protocol (" + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ")";
5876+ if (ret !== constants3.ERROR.OK) {
5877+ const body = data.subarray(offset);
5878+ if (ret === constants3.ERROR.PAUSED_UPGRADE) {
5879+ this.onUpgrade(body);
5880+ } else if (ret === constants3.ERROR.PAUSED) {
5881+ this.paused = true;
5882+ socket.unshift(body);
5883+ } else {
5884+ throw this.createError(ret, body);
58875885 }
5888- throw new HTTPParserError(message, constants3.ERROR[ret], data.slice(offset));
58895886 }
58905887 } catch (err) {
58915888 util.destroy(socket, err);
58925889 }
58935890 }
5891+ finish() {
5892+ assert2(currentParser === null);
5893+ assert2(this.ptr != null);
5894+ assert2(!this.paused);
5895+ const { llhttp } = this;
5896+ let ret;
5897+ try {
5898+ currentParser = this;
5899+ ret = llhttp.llhttp_finish(this.ptr);
5900+ } finally {
5901+ currentParser = null;
5902+ }
5903+ if (ret === constants3.ERROR.OK) {
5904+ return null;
5905+ }
5906+ if (ret === constants3.ERROR.PAUSED || ret === constants3.ERROR.PAUSED_UPGRADE) {
5907+ this.paused = true;
5908+ return null;
5909+ }
5910+ return this.createError(ret, EMPTY_BUF);
5911+ }
5912+ createError(ret, data) {
5913+ const { llhttp, contentLength, bytesRead } = this;
5914+ if (contentLength && bytesRead !== parseInt(contentLength, 10)) {
5915+ return new ResponseContentLengthMismatchError();
5916+ }
5917+ const ptr = llhttp.llhttp_get_error_reason(this.ptr);
5918+ let message = "";
5919+ if (ptr) {
5920+ const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0);
5921+ message = "Response does not match the HTTP/1.1 protocol (" + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ")";
5922+ }
5923+ return new HTTPParserError(message, constants3.ERROR[ret], data);
5924+ }
58945925 destroy() {
58955926 assert2(this.ptr != null);
58965927 assert2(currentParser == null);
@@ -6162,7 +6193,11 @@ var require_client_h1 = __commonJS({
61626193 assert2(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID");
61636194 const parser2 = this[kParser];
61646195 if (err.code === "ECONNRESET" && parser2.statusCode && !parser2.shouldKeepAlive) {
6165- parser2.onMessageComplete();
6196+ const parserErr = parser2.finish();
6197+ if (parserErr) {
6198+ this[kError] = parserErr;
6199+ this[kClient][kOnError](parserErr);
6200+ }
61666201 return;
61676202 }
61686203 this[kError] = err;
@@ -6177,7 +6212,10 @@ var require_client_h1 = __commonJS({
61776212 addListener(socket, "end", function() {
61786213 const parser2 = this[kParser];
61796214 if (parser2.statusCode && !parser2.shouldKeepAlive) {
6180- parser2.onMessageComplete();
6215+ const parserErr = parser2.finish();
6216+ if (parserErr) {
6217+ util.destroy(this, parserErr);
6218+ }
61816219 return;
61826220 }
61836221 util.destroy(this, new SocketError("other side closed", util.getSocketInfo(this)));
@@ -6187,7 +6225,7 @@ var require_client_h1 = __commonJS({
61876225 const parser2 = this[kParser];
61886226 if (parser2) {
61896227 if (!this[kError] && parser2.statusCode && !parser2.shouldKeepAlive) {
6190- parser2.onMessageComplete() ;
6228+ this[kError] = parser2.finish() || this[kError] ;
61916229 }
61926230 this[kParser].destroy();
61936231 this[kParser] = null;
@@ -28643,7 +28681,7 @@ var RequestError = class extends Error {
2864328681};
2864428682
2864528683//
28646- var VERSION2 = "10.0.9 ";
28684+ var VERSION2 = "10.0.10 ";
2864728685var defaults_default = {
2864828686 headers: {
2864928687 "user-agent": `octokit-request.js/${VERSION2} ${getUserAgent()}`
0 commit comments