33const { InvalidArgumentError } = require ( './core/errors' )
44const { kClients, kRunning, kClose, kDestroy, kDispatch } = require ( './core/symbols' )
55const DispatcherBase = require ( './dispatcher-base' )
6- const RedirectHandler = require ( './handler/RedirectHandler' )
76const Pool = require ( './pool' )
87const Client = require ( './client' )
98const util = require ( './core/util' )
109
1110const kOnConnect = Symbol ( 'onConnect' )
1211const kOnDisconnect = Symbol ( 'onDisconnect' )
1312const kOnConnectionError = Symbol ( 'onConnectionError' )
14- const kMaxRedirections = Symbol ( 'maxRedirections' )
1513const kOnDrain = Symbol ( 'onDrain' )
1614const kFactory = Symbol ( 'factory' )
1715const kOptions = Symbol ( 'options' )
@@ -23,7 +21,7 @@ function defaultFactory (origin, opts) {
2321}
2422
2523class Agent extends DispatcherBase {
26- constructor ( { factory = defaultFactory , maxRedirections = 0 , connect, ...options } = { } ) {
24+ constructor ( { factory = defaultFactory , connect, ...options } = { } ) {
2725 super ( )
2826
2927 if ( typeof factory !== 'function' ) {
@@ -34,16 +32,11 @@ class Agent extends DispatcherBase {
3432 throw new InvalidArgumentError ( 'connect must be a function or an object' )
3533 }
3634
37- if ( ! Number . isInteger ( maxRedirections ) || maxRedirections < 0 ) {
38- throw new InvalidArgumentError ( 'maxRedirections must be a positive number' )
39- }
40-
4135 if ( connect && typeof connect !== 'function' ) {
4236 connect = { ...connect }
4337 }
4438
4539 this [ kOptions ] = { ...util . deepClone ( options ) , connect }
46- this [ kMaxRedirections ] = maxRedirections
4740 this [ kFactory ] = factory
4841 this [ kClients ] = new Map ( )
4942
@@ -95,18 +88,6 @@ class Agent extends DispatcherBase {
9588 this [ kClients ] . set ( key , dispatcher )
9689 }
9790
98- if ( this [ kMaxRedirections ] > 0 ) {
99- return dispatcher . dispatch (
100- opts ,
101- new RedirectHandler (
102- dispatcher . dispatch . bind ( dispatcher ) ,
103- this [ kMaxRedirections ] ,
104- opts ,
105- handler
106- )
107- )
108- }
109-
11091 return dispatcher . dispatch ( opts , handler )
11192 }
11293
0 commit comments