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