mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
http: refactor to use min of validateNumber for maxTotalSockets
Remove duplicate implementation by using min of validateNumber. PR-URL: https://github.com/nodejs/node/pull/46115 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
@@ -30,7 +30,6 @@ const {
|
||||
ArrayPrototypeSome,
|
||||
ArrayPrototypeSplice,
|
||||
FunctionPrototypeCall,
|
||||
NumberIsNaN,
|
||||
NumberParseInt,
|
||||
ObjectKeys,
|
||||
ObjectSetPrototypeOf,
|
||||
@@ -50,11 +49,6 @@ let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
|
||||
});
|
||||
const { AsyncResource } = require('async_hooks');
|
||||
const { async_id_symbol } = require('internal/async_hooks').symbols;
|
||||
const {
|
||||
codes: {
|
||||
ERR_OUT_OF_RANGE,
|
||||
},
|
||||
} = require('internal/errors');
|
||||
const {
|
||||
kEmptyObject,
|
||||
once,
|
||||
@@ -124,10 +118,7 @@ function Agent(options) {
|
||||
validateOneOf(this.scheduling, 'scheduling', ['fifo', 'lifo']);
|
||||
|
||||
if (this.maxTotalSockets !== undefined) {
|
||||
validateNumber(this.maxTotalSockets, 'maxTotalSockets');
|
||||
if (this.maxTotalSockets <= 0 || NumberIsNaN(this.maxTotalSockets))
|
||||
throw new ERR_OUT_OF_RANGE('maxTotalSockets', '> 0',
|
||||
this.maxTotalSockets);
|
||||
validateNumber(this.maxTotalSockets, 'maxTotalSockets', 1);
|
||||
} else {
|
||||
this.maxTotalSockets = Infinity;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user