mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
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:
1 parent
2fe562270e
commit
7ff96fca93
1 file changed
+7
-9
+7
-9
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user