diff --git a/lib/_http_server.js b/lib/_http_server.js index ee763daf889a28..97107cead89d5c 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -68,7 +68,10 @@ const { ERR_INVALID_ARG_TYPE, ERR_INVALID_CHAR } = codes; -const { validateInteger } = require('internal/validators'); +const { + validateInteger, + validateBoolean +} = require('internal/validators'); const Buffer = require('buffer').Buffer; const { DTRACE_HTTP_SERVER_REQUEST, @@ -346,11 +349,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 }); @@ -382,9 +382,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;