agent.d.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /// <reference types="node" />
  2. import { Readable } from 'stream';
  3. import { FindProxyForURL } from 'pac-resolver';
  4. import { Agent, AgentCallbackReturn, ClientRequest, RequestOptions } from 'agent-base';
  5. import { PacProxyAgentOptions } from '.';
  6. /**
  7. * The `PacProxyAgent` class.
  8. *
  9. * A few different "protocol" modes are supported (supported protocols are
  10. * backed by the `get-uri` module):
  11. *
  12. * - "pac+data", "data" - refers to an embedded "data:" URI
  13. * - "pac+file", "file" - refers to a local file
  14. * - "pac+ftp", "ftp" - refers to a file located on an FTP server
  15. * - "pac+http", "http" - refers to an HTTP endpoint
  16. * - "pac+https", "https" - refers to an HTTPS endpoint
  17. *
  18. * @api public
  19. */
  20. export default class PacProxyAgent extends Agent {
  21. uri: string;
  22. opts: PacProxyAgentOptions;
  23. cache?: Readable;
  24. resolver?: FindProxyForURL;
  25. resolverHash: string;
  26. resolverPromise?: Promise<FindProxyForURL>;
  27. constructor(uri: string, opts?: PacProxyAgentOptions);
  28. private clearResolverPromise;
  29. /**
  30. * Loads the PAC proxy file from the source if necessary, and returns
  31. * a generated `FindProxyForURL()` resolver function to use.
  32. *
  33. * @api private
  34. */
  35. private getResolver;
  36. private loadResolver;
  37. /**
  38. * Loads the contents of the PAC proxy file.
  39. *
  40. * @api private
  41. */
  42. private loadPacFile;
  43. /**
  44. * Called when the node-core HTTP client library is creating a new HTTP request.
  45. *
  46. * @api protected
  47. */
  48. callback(req: ClientRequest, opts: RequestOptions): Promise<AgentCallbackReturn>;
  49. }