Skip to content

Commit

Permalink
Fix body parsing
Browse files Browse the repository at this point in the history
This was broken by: nodejs/node@b970634
  • Loading branch information
kylecarbs authored and Jimbly committed Jan 9, 2025
1 parent 48c3de1 commit 9e5daea
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions http-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ HTTPParser.prototype.reinitialize = HTTPParser;
HTTPParser.prototype.close =
HTTPParser.prototype.pause =
HTTPParser.prototype.resume =
HTTPParser.prototype.remove =
HTTPParser.prototype.free = function () {};
HTTPParser.prototype._compatMode0_11 = false;
HTTPParser.prototype.getAsyncId = function() { return 0; };
Expand Down Expand Up @@ -394,7 +395,8 @@ HTTPParser.prototype.BODY_CHUNKHEAD = function () {

HTTPParser.prototype.BODY_CHUNK = function () {
var length = Math.min(this.end - this.offset, this.body_bytes);
this.userCall()(this[kOnBody](this.chunk, this.offset, length));
// 0, length are for backwards compatibility. See: https://github.com/creationix/http-parser-js/pull/98
this.userCall()(this[kOnBody](this.chunk.slice(this.offset, this.offset + length), 0, length));
this.offset += length;
this.body_bytes -= length;
if (!this.body_bytes) {
Expand Down Expand Up @@ -429,14 +431,15 @@ HTTPParser.prototype.BODY_CHUNKTRAILERS = function () {
};

HTTPParser.prototype.BODY_RAW = function () {
var length = this.end - this.offset;
this.userCall()(this[kOnBody](this.chunk, this.offset, length));
// 0, length are for backwards compatibility. See: https://github.com/creationix/http-parser-js/pull/98
this.userCall()(this[kOnBody](this.chunk.slice(this.offset, this.end), 0, this.end - this.offset));
this.offset = this.end;
};

HTTPParser.prototype.BODY_SIZED = function () {
var length = Math.min(this.end - this.offset, this.body_bytes);
this.userCall()(this[kOnBody](this.chunk, this.offset, length));
// 0, length are for backwards compatibility. See: https://github.com/creationix/http-parser-js/pull/98
this.userCall()(this[kOnBody](this.chunk.slice(this.offset, this.offset + length), 0, length));
this.offset += length;
this.body_bytes -= length;
if (!this.body_bytes) {
Expand Down

0 comments on commit 9e5daea

Please sign in to comment.