Skip to content

Commit

Permalink
Remove assert
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecarbs authored and Jimbly committed Jan 9, 2025
1 parent 88c6653 commit 48c3de1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions http-parser.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*jshint node:true */

var assert = require('assert');

exports.HTTPParser = HTTPParser;
function HTTPParser(type) {
assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE || type === undefined);
if (type !== undefined && type !== HTTPParser.REQUEST && type !== HTTPParser.RESPONSE) {
throw new Error('type must be REQUEST or RESPONSE');
}
if (type === undefined) {
// Node v12+
} else {
Expand All @@ -13,7 +13,9 @@ function HTTPParser(type) {
this.maxHeaderSize=HTTPParser.maxHeaderSize
}
HTTPParser.prototype.initialize = function (type, async_resource) {
assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE);
if (type !== HTTPParser.REQUEST && type !== HTTPParser.RESPONSE) {
throw new Error('type must be REQUEST or RESPONSE');
}
this.type = type;
this.state = type + '_LINE';
this.info = {
Expand Down Expand Up @@ -405,7 +407,9 @@ HTTPParser.prototype.BODY_CHUNKEMPTYLINE = function () {
if (line === undefined) {
return;
}
assert.equal(line, '');
if (line !== '') {
throw new Error('Expected empty line');
}
this.state = 'BODY_CHUNKHEAD';
};

Expand Down

0 comments on commit 48c3de1

Please sign in to comment.