UNPKG

1.52 kBTypeScriptView Raw
1/// <reference types="node" />
2/// <reference types="node" />
3/// <reference types="node" />
4/// <reference types="node" />
5import * as net from 'net';
6import * as tls from 'tls';
7import * as http from 'http';
8import type { Duplex } from 'stream';
9export * from './helpers';
10interface HttpConnectOpts extends net.TcpNetConnectOpts {
11 secureEndpoint: false;
12 protocol?: string;
13}
14interface HttpsConnectOpts extends tls.ConnectionOptions {
15 secureEndpoint: true;
16 protocol?: string;
17 port: number;
18}
19export type AgentConnectOpts = HttpConnectOpts | HttpsConnectOpts;
20declare const INTERNAL: unique symbol;
21export declare abstract class Agent extends http.Agent {
22 private [INTERNAL];
23 options: Partial<net.TcpNetConnectOpts & tls.ConnectionOptions>;
24 keepAlive: boolean;
25 constructor(opts?: http.AgentOptions);
26 abstract connect(req: http.ClientRequest, options: AgentConnectOpts): Promise<Duplex | http.Agent> | Duplex | http.Agent;
27 /**
28 * Determine whether this is an `http` or `https` request.
29 */
30 isSecureEndpoint(options?: AgentConnectOpts): boolean;
31 private incrementSockets;
32 private decrementSockets;
33 getName(options: AgentConnectOpts): string;
34 createSocket(req: http.ClientRequest, options: AgentConnectOpts, cb: (err: Error | null, s?: Duplex) => void): void;
35 createConnection(): Duplex;
36 get defaultPort(): number;
37 set defaultPort(v: number);
38 get protocol(): string;
39 set protocol(v: string);
40}
41//# sourceMappingURL=index.d.ts.map
\No newline at end of file