11cb0ef41Sopenharmony_ci# Agent 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciExtends: `undici.Dispatcher` 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciAgent allow dispatching requests against multiple different origins. 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciRequests are not guaranteed to be dispatched in order of invocation. 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci## `new undici.Agent([options])` 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciArguments: 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci* **options** `AgentOptions` (optional) 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciReturns: `Agent` 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci### Parameter: `AgentOptions` 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ciExtends: [`PoolOptions`](Pool.md#parameter-pooloptions) 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci* **factory** `(origin: URL, opts: Object) => Dispatcher` - Default: `(origin, opts) => new Pool(origin, opts)` 221cb0ef41Sopenharmony_ci* **maxRedirections** `Integer` - Default: `0`. The number of HTTP redirection to follow unless otherwise specified in `DispatchOptions`. 231cb0ef41Sopenharmony_ci* **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. 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci## Instance Properties 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci### `Agent.closed` 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ciImplements [Client.closed](Client.md#clientclosed) 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ci### `Agent.destroyed` 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ciImplements [Client.destroyed](Client.md#clientdestroyed) 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci## Instance Methods 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci### `Agent.close([callback])` 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ciImplements [`Dispatcher.close([callback])`](Dispatcher.md#dispatcherclosecallback-promise). 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_ci### `Agent.destroy([error, callback])` 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ciImplements [`Dispatcher.destroy([error, callback])`](Dispatcher.md#dispatcherdestroyerror-callback-promise). 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci### `Agent.dispatch(options, handler: AgentDispatchOptions)` 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_ciImplements [`Dispatcher.dispatch(options, handler)`](Dispatcher.md#dispatcherdispatchoptions-handler). 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ci#### Parameter: `AgentDispatchOptions` 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ciExtends: [`DispatchOptions`](Dispatcher.md#parameter-dispatchoptions) 521cb0ef41Sopenharmony_ci 531cb0ef41Sopenharmony_ci* **origin** `string | URL` 541cb0ef41Sopenharmony_ci* **maxRedirections** `Integer`. 551cb0ef41Sopenharmony_ci 561cb0ef41Sopenharmony_ciImplements [`Dispatcher.destroy([error, callback])`](Dispatcher.md#dispatcherdestroyerror-callback-promise). 571cb0ef41Sopenharmony_ci 581cb0ef41Sopenharmony_ci### `Agent.connect(options[, callback])` 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_ciSee [`Dispatcher.connect(options[, callback])`](Dispatcher.md#dispatcherconnectoptions-callback). 611cb0ef41Sopenharmony_ci 621cb0ef41Sopenharmony_ci### `Agent.dispatch(options, handler)` 631cb0ef41Sopenharmony_ci 641cb0ef41Sopenharmony_ciImplements [`Dispatcher.dispatch(options, handler)`](Dispatcher.md#dispatcherdispatchoptions-handler). 651cb0ef41Sopenharmony_ci 661cb0ef41Sopenharmony_ci### `Agent.pipeline(options, handler)` 671cb0ef41Sopenharmony_ci 681cb0ef41Sopenharmony_ciSee [`Dispatcher.pipeline(options, handler)`](Dispatcher.md#dispatcherpipelineoptions-handler). 691cb0ef41Sopenharmony_ci 701cb0ef41Sopenharmony_ci### `Agent.request(options[, callback])` 711cb0ef41Sopenharmony_ci 721cb0ef41Sopenharmony_ciSee [`Dispatcher.request(options [, callback])`](Dispatcher.md#dispatcherrequestoptions-callback). 731cb0ef41Sopenharmony_ci 741cb0ef41Sopenharmony_ci### `Agent.stream(options, factory[, callback])` 751cb0ef41Sopenharmony_ci 761cb0ef41Sopenharmony_ciSee [`Dispatcher.stream(options, factory[, callback])`](Dispatcher.md#dispatcherstreamoptions-factory-callback). 771cb0ef41Sopenharmony_ci 781cb0ef41Sopenharmony_ci### `Agent.upgrade(options[, callback])` 791cb0ef41Sopenharmony_ci 801cb0ef41Sopenharmony_ciSee [`Dispatcher.upgrade(options[, callback])`](Dispatcher.md#dispatcherupgradeoptions-callback). 81