agent.d.ts 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. import { URL } from 'url'
  2. import Pool from './pool'
  3. import Dispatcher from "./dispatcher";
  4. export default Agent
  5. declare class Agent extends Dispatcher{
  6. constructor(opts?: Agent.Options)
  7. /** `true` after `dispatcher.close()` has been called. */
  8. closed: boolean;
  9. /** `true` after `dispatcher.destroyed()` has been called or `dispatcher.close()` has been called and the dispatcher shutdown has completed. */
  10. destroyed: boolean;
  11. /** Dispatches a request. */
  12. dispatch(options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
  13. }
  14. declare namespace Agent {
  15. export interface Options extends Pool.Options {
  16. /** Default: `(origin, opts) => new Pool(origin, opts)`. */
  17. factory?(origin: string | URL, opts: Object): Dispatcher;
  18. /** Integer. Default: `0` */
  19. maxRedirections?: number;
  20. interceptors?: { Agent?: readonly Dispatcher.DispatchInterceptor[] } & Pool.Options["interceptors"]
  21. }
  22. export interface DispatchOptions extends Dispatcher.DispatchOptions {
  23. /** Integer. */
  24. maxRedirections?: number;
  25. }
  26. }