Add http.Agent to node.js typings

This commit is contained in:
Rogier Schouten
2015-03-04 13:57:57 +01:00
parent bb465f2cc7
commit 369935805c
3 changed files with 81 additions and 2 deletions

37
node/node.d.ts vendored
View File

@@ -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;