http: used already defined validator for boolean check

We already importing the validator for integer check. So leveraging the
boolean check validator to remove already defined logic in the code and
thus making it DRY.

PR-URL: https://github.com/nodejs/node/pull/33731
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
Yash Ladha authored and Shelley Vohr committed 2020-06-30 09:34:28 -07:00
1 parent 2fe562270e
commit 7ff96fca93
1 file changed
+7 -9
+7 -9
View File
@@ -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;