[d24f17c] | 1 | # Agent
|
---|
| 2 |
|
---|
| 3 | Extends: `undici.Dispatcher`
|
---|
| 4 |
|
---|
| 5 | Agent allow dispatching requests against multiple different origins.
|
---|
| 6 |
|
---|
| 7 | Requests are not guaranteed to be dispatched in order of invocation.
|
---|
| 8 |
|
---|
| 9 | ## `new undici.Agent([options])`
|
---|
| 10 |
|
---|
| 11 | Arguments:
|
---|
| 12 |
|
---|
| 13 | * **options** `AgentOptions` (optional)
|
---|
| 14 |
|
---|
| 15 | Returns: `Agent`
|
---|
| 16 |
|
---|
| 17 | ### Parameter: `AgentOptions`
|
---|
| 18 |
|
---|
| 19 | Extends: [`PoolOptions`](Pool.md#parameter-pooloptions)
|
---|
| 20 |
|
---|
| 21 | * **factory** `(origin: URL, opts: Object) => Dispatcher` - Default: `(origin, opts) => new Pool(origin, opts)`
|
---|
| 22 | * **maxRedirections** `Integer` - Default: `0`. The number of HTTP redirection to follow unless otherwise specified in `DispatchOptions`.
|
---|
| 23 | * **interceptors** `{ Agent: DispatchInterceptor[] }` - Default: `[RedirectInterceptor]` - A list of interceptors that are applied to the dispatch method. Additional logic can be applied (such as, but not limited to: 302 status code handling, authentication, cookies, compression and caching). Note that the behavior of interceptors is Experimental and might change at any given time.
|
---|
| 24 |
|
---|
| 25 | ## Instance Properties
|
---|
| 26 |
|
---|
| 27 | ### `Agent.closed`
|
---|
| 28 |
|
---|
| 29 | Implements [Client.closed](Client.md#clientclosed)
|
---|
| 30 |
|
---|
| 31 | ### `Agent.destroyed`
|
---|
| 32 |
|
---|
| 33 | Implements [Client.destroyed](Client.md#clientdestroyed)
|
---|
| 34 |
|
---|
| 35 | ## Instance Methods
|
---|
| 36 |
|
---|
| 37 | ### `Agent.close([callback])`
|
---|
| 38 |
|
---|
| 39 | Implements [`Dispatcher.close([callback])`](Dispatcher.md#dispatcherclosecallback-promise).
|
---|
| 40 |
|
---|
| 41 | ### `Agent.destroy([error, callback])`
|
---|
| 42 |
|
---|
| 43 | Implements [`Dispatcher.destroy([error, callback])`](Dispatcher.md#dispatcherdestroyerror-callback-promise).
|
---|
| 44 |
|
---|
| 45 | ### `Agent.dispatch(options, handler: AgentDispatchOptions)`
|
---|
| 46 |
|
---|
| 47 | Implements [`Dispatcher.dispatch(options, handler)`](Dispatcher.md#dispatcherdispatchoptions-handler).
|
---|
| 48 |
|
---|
| 49 | #### Parameter: `AgentDispatchOptions`
|
---|
| 50 |
|
---|
| 51 | Extends: [`DispatchOptions`](Dispatcher.md#parameter-dispatchoptions)
|
---|
| 52 |
|
---|
| 53 | * **origin** `string | URL`
|
---|
| 54 | * **maxRedirections** `Integer`.
|
---|
| 55 |
|
---|
| 56 | Implements [`Dispatcher.destroy([error, callback])`](Dispatcher.md#dispatcherdestroyerror-callback-promise).
|
---|
| 57 |
|
---|
| 58 | ### `Agent.connect(options[, callback])`
|
---|
| 59 |
|
---|
| 60 | See [`Dispatcher.connect(options[, callback])`](Dispatcher.md#dispatcherconnectoptions-callback).
|
---|
| 61 |
|
---|
| 62 | ### `Agent.dispatch(options, handler)`
|
---|
| 63 |
|
---|
| 64 | Implements [`Dispatcher.dispatch(options, handler)`](Dispatcher.md#dispatcherdispatchoptions-handler).
|
---|
| 65 |
|
---|
| 66 | ### `Agent.pipeline(options, handler)`
|
---|
| 67 |
|
---|
| 68 | See [`Dispatcher.pipeline(options, handler)`](Dispatcher.md#dispatcherpipelineoptions-handler).
|
---|
| 69 |
|
---|
| 70 | ### `Agent.request(options[, callback])`
|
---|
| 71 |
|
---|
| 72 | See [`Dispatcher.request(options [, callback])`](Dispatcher.md#dispatcherrequestoptions-callback).
|
---|
| 73 |
|
---|
| 74 | ### `Agent.stream(options, factory[, callback])`
|
---|
| 75 |
|
---|
| 76 | See [`Dispatcher.stream(options, factory[, callback])`](Dispatcher.md#dispatcherstreamoptions-factory-callback).
|
---|
| 77 |
|
---|
| 78 | ### `Agent.upgrade(options[, callback])`
|
---|
| 79 |
|
---|
| 80 | See [`Dispatcher.upgrade(options[, callback])`](Dispatcher.md#dispatcherupgradeoptions-callback).
|
---|