Skip to content

Commit 1a90d32

Browse files
yashLadhajasnell
authored andcommitted
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: #33731 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 4af2539 commit 1a90d32

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

lib/_http_server.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ const {
6868
ERR_INVALID_ARG_TYPE,
6969
ERR_INVALID_CHAR
7070
} = codes;
71-
const { validateInteger } = require('internal/validators');
71+
const {
72+
validateInteger,
73+
validateBoolean
74+
} = require('internal/validators');
7275
const Buffer = require('buffer').Buffer;
7376
const {
7477
DTRACE_HTTP_SERVER_REQUEST,
@@ -346,11 +349,8 @@ function Server(options, requestListener) {
346349
this.maxHeaderSize = maxHeaderSize;
347350

348351
const insecureHTTPParser = options.insecureHTTPParser;
349-
if (insecureHTTPParser !== undefined &&
350-
typeof insecureHTTPParser !== 'boolean') {
351-
throw new ERR_INVALID_ARG_TYPE(
352-
'options.insecureHTTPParser', 'boolean', insecureHTTPParser);
353-
}
352+
if (insecureHTTPParser !== undefined)
353+
validateBoolean(insecureHTTPParser, 'options.insecureHTTPParser');
354354
this.insecureHTTPParser = insecureHTTPParser;
355355

356356
net.Server.call(this, { allowHalfOpen: true });
@@ -382,9 +382,7 @@ Server.prototype.setTimeout = function setTimeout(msecs, callback) {
382382
return this;
383383
};
384384

385-
Server.prototype[EE.captureRejectionSymbol] = function(
386-
err, event, ...args) {
387-
385+
Server.prototype[EE.captureRejectionSymbol] = function(err, event, ...args) {
388386
switch (event) {
389387
case 'request':
390388
const [ , res] = args;

0 commit comments

Comments
 (0)