diff --git a/lib/_http_server.js b/lib/_http_server.js index c8b27dcd42cb5b..680fadba715f07 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -62,7 +62,10 @@ const { ERR_INVALID_ARG_TYPE, ERR_INVALID_CHAR } = require('internal/errors').codes; -const { validateInteger } = require('internal/validators'); +const { + validateInteger, + validateBoolean +} = require('internal/validators'); const Buffer = require('buffer').Buffer; const { DTRACE_HTTP_SERVER_REQUEST, @@ -336,11 +339,8 @@ function Server(options, requestListener) { this.maxHeaderSize = maxHeaderSize; const insecureHTTPParser = options.insecureHTTPParser; - if (insecureHTTPParser !== undefined && - typeof insecureHTTPParser !== 'boolean') { - throw new ERR_INVALID_ARG_TYPE( - 'options.insecureHTTPParser', 'boolean', insecureHTTPParser); - } + if (insecureHTTPParser !== undefined) + validateBoolean(insecureHTTPParser, 'options.insecureHTTPParser'); this.insecureHTTPParser = insecureHTTPParser; net.Server.call(this, { allowHalfOpen: true }); @@ -372,9 +372,7 @@ Server.prototype.setTimeout = function setTimeout(msecs, callback) { return this; }; -Server.prototype[EE.captureRejectionSymbol] = function( - err, event, ...args) { - +Server.prototype[EE.captureRejectionSymbol] = function(err, event, ...args) { switch (event) { case 'request': const [ , res] = args;