Skip to content

Commit 48c3de1

Browse files
kylecarbsJimbly
authored andcommitted
Remove assert
1 parent 88c6653 commit 48c3de1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

http-parser.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*jshint node:true */
22

3-
var assert = require('assert');
4-
53
exports.HTTPParser = HTTPParser;
64
function HTTPParser(type) {
7-
assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE || type === undefined);
5+
if (type !== undefined && type !== HTTPParser.REQUEST && type !== HTTPParser.RESPONSE) {
6+
throw new Error('type must be REQUEST or RESPONSE');
7+
}
88
if (type === undefined) {
99
// Node v12+
1010
} else {
@@ -13,7 +13,9 @@ function HTTPParser(type) {
1313
this.maxHeaderSize=HTTPParser.maxHeaderSize
1414
}
1515
HTTPParser.prototype.initialize = function (type, async_resource) {
16-
assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE);
16+
if (type !== HTTPParser.REQUEST && type !== HTTPParser.RESPONSE) {
17+
throw new Error('type must be REQUEST or RESPONSE');
18+
}
1719
this.type = type;
1820
this.state = type + '_LINE';
1921
this.info = {
@@ -405,7 +407,9 @@ HTTPParser.prototype.BODY_CHUNKEMPTYLINE = function () {
405407
if (line === undefined) {
406408
return;
407409
}
408-
assert.equal(line, '');
410+
if (line !== '') {
411+
throw new Error('Expected empty line');
412+
}
409413
this.state = 'BODY_CHUNKHEAD';
410414
};
411415

0 commit comments

Comments
 (0)