File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 1
1
/*jshint node:true */
2
2
3
- var assert = require ( 'assert' ) ;
4
-
5
3
exports . HTTPParser = HTTPParser ;
6
4
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
+ }
8
8
if ( type === undefined ) {
9
9
// Node v12+
10
10
} else {
@@ -13,7 +13,9 @@ function HTTPParser(type) {
13
13
this . maxHeaderSize = HTTPParser . maxHeaderSize
14
14
}
15
15
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
+ }
17
19
this . type = type ;
18
20
this . state = type + '_LINE' ;
19
21
this . info = {
@@ -405,7 +407,9 @@ HTTPParser.prototype.BODY_CHUNKEMPTYLINE = function () {
405
407
if ( line === undefined ) {
406
408
return ;
407
409
}
408
- assert . equal ( line , '' ) ;
410
+ if ( line !== '' ) {
411
+ throw new Error ( 'Expected empty line' ) ;
412
+ }
409
413
this . state = 'BODY_CHUNKHEAD' ;
410
414
} ;
411
415
You can’t perform that action at this time.
0 commit comments