UNPKG

2.19 kBTypeScriptView Raw
1declare module "https" {
2 import * as tls from "tls";
3 import * as events from "events";
4 import * as http from "http";
5 import { URL } from "url";
6
7 type ServerOptions = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions;
8
9 type RequestOptions = http.RequestOptions & tls.SecureContextOptions & {
10 rejectUnauthorized?: boolean; // Defaults to true
11 servername?: string; // SNI TLS Extension
12 };
13
14 interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
15 rejectUnauthorized?: boolean;
16 maxCachedSessions?: number;
17 }
18
19 class Agent extends http.Agent {
20 constructor(options?: AgentOptions);
21 options: AgentOptions;
22 }
23
24 class Server extends tls.Server {
25 constructor(options: ServerOptions, requestListener?: http.RequestListener);
26
27 setTimeout(callback: () => void): this;
28 setTimeout(msecs?: number, callback?: () => void): this;
29 /**
30 * Limits maximum incoming headers count. If set to 0, no limit will be applied.
31 * @default 2000
32 * {@link https://nodejs.org/api/http.html#http_server_maxheaderscount}
33 */
34 maxHeadersCount: number | null;
35 timeout: number;
36 /**
37 * Limit the amount of time the parser will wait to receive the complete HTTP headers.
38 * @default 40000
39 * {@link https://nodejs.org/api/http.html#http_server_headerstimeout}
40 */
41 headersTimeout: number;
42 keepAliveTimeout: number;
43 }
44
45 function createServer(options: ServerOptions, requestListener?: http.RequestListener): Server;
46 function request(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
47 function request(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
48 function get(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
49 function get(url: string | URL, options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
50 let globalAgent: Agent;
51}