You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.d.ts 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import * as http from 'http';
  2. import * as https from 'https';
  3. import * as net from 'net';
  4. interface PlainObject {
  5. [key: string]: any;
  6. }
  7. declare class HttpAgent extends http.Agent {
  8. constructor(opts?: AgentKeepAlive.HttpOptions);
  9. readonly statusChanged: boolean;
  10. createConnection(options: net.NetConnectOpts, cb?: Function): net.Socket;
  11. createSocket(req: http.IncomingMessage, options: http.RequestOptions, cb: Function): void;
  12. getCurrentStatus(): AgentKeepAlive.AgentStatus;
  13. }
  14. interface Constants {
  15. CURRENT_ID: Symbol;
  16. CREATE_ID: Symbol;
  17. INIT_SOCKET: Symbol;
  18. CREATE_HTTPS_CONNECTION: Symbol;
  19. SOCKET_CREATED_TIME: Symbol;
  20. SOCKET_NAME: Symbol;
  21. SOCKET_REQUEST_COUNT: Symbol;
  22. SOCKET_REQUEST_FINISHED_COUNT: Symbol;
  23. }
  24. declare class AgentKeepAlive extends HttpAgent {}
  25. declare namespace AgentKeepAlive {
  26. export interface AgentStatus {
  27. createSocketCount: number;
  28. createSocketErrorCount: number;
  29. closeSocketCount: number;
  30. errorSocketCount: number;
  31. timeoutSocketCount: number;
  32. requestCount: number;
  33. freeSockets: PlainObject;
  34. sockets: PlainObject;
  35. requests: PlainObject;
  36. }
  37. interface CommonHttpOption {
  38. keepAlive?: boolean | undefined;
  39. freeSocketTimeout?: number | undefined;
  40. freeSocketKeepAliveTimeout?: number | undefined;
  41. timeout?: number | undefined;
  42. socketActiveTTL?: number | undefined;
  43. }
  44. export interface HttpOptions extends http.AgentOptions, CommonHttpOption { }
  45. export interface HttpsOptions extends https.AgentOptions, CommonHttpOption { }
  46. export class HttpsAgent extends https.Agent {
  47. constructor(opts?: HttpsOptions);
  48. readonly statusChanged: boolean;
  49. createConnection(options: net.NetConnectOpts, cb?: Function): net.Socket;
  50. createSocket(req: http.IncomingMessage, options: http.RequestOptions, cb: Function): void;
  51. getCurrentStatus(): AgentStatus;
  52. }
  53. export const constants: Constants;
  54. }
  55. export = AgentKeepAlive;