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