Skip to content

Commit

Permalink
http: used already defined validator for boolean check
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
yashLadha authored and codebytere committed Jun 27, 2020
1 parent 0dbad26 commit a0a61b8
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a0a61b8

Please sign in to comment.