mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 11:57:33 +08:00
Add http.Agent to node.js typings
This commit is contained in:
37
node/node.d.ts
vendored
37
node/node.d.ts
vendored
@@ -349,7 +349,42 @@ declare module "http" {
|
||||
pause(): void;
|
||||
resume(): void;
|
||||
}
|
||||
export interface Agent { maxSockets: number; sockets: any; requests: any; }
|
||||
|
||||
export interface AgentOptions {
|
||||
/**
|
||||
* Keep sockets around in a pool to be used by other requests in the future. Default = false
|
||||
*/
|
||||
keepAlive?: boolean;
|
||||
/**
|
||||
* When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000.
|
||||
* Only relevant if keepAlive is set to true.
|
||||
*/
|
||||
keepAliveMsecs?: number;
|
||||
/**
|
||||
* Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity
|
||||
*/
|
||||
maxSockets?: number;
|
||||
/**
|
||||
* Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256.
|
||||
*/
|
||||
maxFreeSockets?: number;
|
||||
}
|
||||
|
||||
export class Agent {
|
||||
maxSockets: number;
|
||||
sockets: any;
|
||||
requests: any;
|
||||
|
||||
constructor(opts?: AgentOptions);
|
||||
|
||||
/**
|
||||
* Destroy any sockets that are currently in use by the agent.
|
||||
* It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled,
|
||||
* then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise,
|
||||
* sockets may hang open for quite a long time before the server terminates them.
|
||||
*/
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
export var STATUS_CODES: {
|
||||
[errorCode: number]: string;
|
||||
|
||||
Reference in New Issue
Block a user