• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Agent
2
3Extends: `undici.Dispatcher`
4
5Agent allow dispatching requests against multiple different origins.
6
7Requests are not guaranteed to be dispatched in order of invocation.
8
9## `new undici.Agent([options])`
10
11Arguments:
12
13* **options** `AgentOptions` (optional)
14
15Returns: `Agent`
16
17### Parameter: `AgentOptions`
18
19Extends: [`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
29Implements [Client.closed](Client.md#clientclosed)
30
31### `Agent.destroyed`
32
33Implements [Client.destroyed](Client.md#clientdestroyed)
34
35## Instance Methods
36
37### `Agent.close([callback])`
38
39Implements [`Dispatcher.close([callback])`](Dispatcher.md#dispatcherclosecallback-promise).
40
41### `Agent.destroy([error, callback])`
42
43Implements [`Dispatcher.destroy([error, callback])`](Dispatcher.md#dispatcherdestroyerror-callback-promise).
44
45### `Agent.dispatch(options, handler: AgentDispatchOptions)`
46
47Implements [`Dispatcher.dispatch(options, handler)`](Dispatcher.md#dispatcherdispatchoptions-handler).
48
49#### Parameter: `AgentDispatchOptions`
50
51Extends: [`DispatchOptions`](Dispatcher.md#parameter-dispatchoptions)
52
53* **origin** `string | URL`
54* **maxRedirections** `Integer`.
55
56Implements [`Dispatcher.destroy([error, callback])`](Dispatcher.md#dispatcherdestroyerror-callback-promise).
57
58### `Agent.connect(options[, callback])`
59
60See [`Dispatcher.connect(options[, callback])`](Dispatcher.md#dispatcherconnectoptions-callback).
61
62### `Agent.dispatch(options, handler)`
63
64Implements [`Dispatcher.dispatch(options, handler)`](Dispatcher.md#dispatcherdispatchoptions-handler).
65
66### `Agent.pipeline(options, handler)`
67
68See [`Dispatcher.pipeline(options, handler)`](Dispatcher.md#dispatcherpipelineoptions-handler).
69
70### `Agent.request(options[, callback])`
71
72See [`Dispatcher.request(options [, callback])`](Dispatcher.md#dispatcherrequestoptions-callback).
73
74### `Agent.stream(options, factory[, callback])`
75
76See [`Dispatcher.stream(options, factory[, callback])`](Dispatcher.md#dispatcherstreamoptions-factory-callback).
77
78### `Agent.upgrade(options[, callback])`
79
80See [`Dispatcher.upgrade(options[, callback])`](Dispatcher.md#dispatcherupgradeoptions-callback).
81