source: trip-planner-front/node_modules/agent-base/dist/src/index.d.ts@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/// <reference types="node" />
2import net from 'net';
3import http from 'http';
4import https from 'https';
5import { Duplex } from 'stream';
6import { EventEmitter } from 'events';
7declare function createAgent(opts?: createAgent.AgentOptions): createAgent.Agent;
8declare function createAgent(callback: createAgent.AgentCallback, opts?: createAgent.AgentOptions): createAgent.Agent;
9declare namespace createAgent {
10 interface ClientRequest extends http.ClientRequest {
11 _last?: boolean;
12 _hadError?: boolean;
13 method: string;
14 }
15 interface AgentRequestOptions {
16 host?: string;
17 path?: string;
18 port: number;
19 }
20 interface HttpRequestOptions extends AgentRequestOptions, Omit<http.RequestOptions, keyof AgentRequestOptions> {
21 secureEndpoint: false;
22 }
23 interface HttpsRequestOptions extends AgentRequestOptions, Omit<https.RequestOptions, keyof AgentRequestOptions> {
24 secureEndpoint: true;
25 }
26 type RequestOptions = HttpRequestOptions | HttpsRequestOptions;
27 type AgentLike = Pick<createAgent.Agent, 'addRequest'> | http.Agent;
28 type AgentCallbackReturn = Duplex | AgentLike;
29 type AgentCallbackCallback = (err?: Error | null, socket?: createAgent.AgentCallbackReturn) => void;
30 type AgentCallbackPromise = (req: createAgent.ClientRequest, opts: createAgent.RequestOptions) => createAgent.AgentCallbackReturn | Promise<createAgent.AgentCallbackReturn>;
31 type AgentCallback = typeof Agent.prototype.callback;
32 type AgentOptions = {
33 timeout?: number;
34 };
35 /**
36 * Base `http.Agent` implementation.
37 * No pooling/keep-alive is implemented by default.
38 *
39 * @param {Function} callback
40 * @api public
41 */
42 class Agent extends EventEmitter {
43 timeout: number | null;
44 maxFreeSockets: number;
45 maxTotalSockets: number;
46 maxSockets: number;
47 sockets: {
48 [key: string]: net.Socket[];
49 };
50 freeSockets: {
51 [key: string]: net.Socket[];
52 };
53 requests: {
54 [key: string]: http.IncomingMessage[];
55 };
56 options: https.AgentOptions;
57 private promisifiedCallback?;
58 private explicitDefaultPort?;
59 private explicitProtocol?;
60 constructor(callback?: createAgent.AgentCallback | createAgent.AgentOptions, _opts?: createAgent.AgentOptions);
61 get defaultPort(): number;
62 set defaultPort(v: number);
63 get protocol(): string;
64 set protocol(v: string);
65 callback(req: createAgent.ClientRequest, opts: createAgent.RequestOptions, fn: createAgent.AgentCallbackCallback): void;
66 callback(req: createAgent.ClientRequest, opts: createAgent.RequestOptions): createAgent.AgentCallbackReturn | Promise<createAgent.AgentCallbackReturn>;
67 /**
68 * Called by node-core's "_http_client.js" module when creating
69 * a new HTTP request with this Agent instance.
70 *
71 * @api public
72 */
73 addRequest(req: ClientRequest, _opts: RequestOptions): void;
74 freeSocket(socket: net.Socket, opts: AgentOptions): void;
75 destroy(): void;
76 }
77}
78export = createAgent;
Note: See TracBrowser for help on using the repository browser.