1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | import * as http from 'http';
|
10 | import * as https from 'https';
|
11 |
|
12 |
|
13 | export namespace agent {
|
14 | class Agent extends https.Agent {}
|
15 | class PlainAgent extends http.Agent {}
|
16 | function create(base: any, options: AgentOptions): Agent | PlainAgent;
|
17 |
|
18 | interface AgentOptions extends https.AgentOptions {
|
19 | port?: number | undefined;
|
20 | spdy?: {
|
21 | plain?: boolean | undefined,
|
22 | ssl?: boolean | undefined,
|
23 | 'x-forwarded-for'?: string | undefined,
|
24 | protocol?: string | undefined,
|
25 | protocols?: string[] | undefined
|
26 | } | undefined;
|
27 | }
|
28 | }
|
29 |
|
30 |
|
31 | export interface Handle {
|
32 | create(options: object, stream: any, socket: Socket): Handle;
|
33 | getStream(callback?: (stream: any) => void): any;
|
34 | assignSocket(socket: Socket, options: object): void;
|
35 | assignClientRequest(req: any): void;
|
36 | assignRequest(req: any): void;
|
37 | assignResponse(res: any): void;
|
38 | emitRequest(): void;
|
39 | emitResponse(status: any, headers: any): void;
|
40 | }
|
41 |
|
42 |
|
43 | export namespace request {
|
44 | function onNewListener(type: string): void;
|
45 | }
|
46 |
|
47 |
|
48 | export namespace response {
|
49 | function writeHead(statusCode: number, reason: string, obj: object): void;
|
50 | function writeHead(statusCode: number, obj: object): void;
|
51 | function end(data: any, encoding: string, callback: () => void): void;
|
52 | }
|
53 |
|
54 |
|
55 | export namespace server {
|
56 | type Server = https.Server;
|
57 | type PlainServer = http.Server;
|
58 | type IncomingMessage = http.IncomingMessage;
|
59 | interface ServerResponse extends http.ServerResponse {
|
60 | push(filename: string, options: PushOptions): any;
|
61 | }
|
62 | function create(base: any,
|
63 | options: https.ServerOptions,
|
64 | handler: (request: IncomingMessage, response: ServerResponse | http.ServerResponse) => void): Server;
|
65 | function create(options: https.ServerOptions,
|
66 | handler: (request: IncomingMessage, response: http.ServerResponse) => void): Server;
|
67 | function create(handler: (request: IncomingMessage, response: ServerResponse | http.ServerResponse) => void): Server;
|
68 |
|
69 | type Protocol =
|
70 | 'h2'
|
71 | | 'spdy/3.1'
|
72 | | 'spdy/3'
|
73 | | 'spdy/2'
|
74 | | 'http/1.1'
|
75 | | 'http/1.0';
|
76 |
|
77 | interface PushOptions {
|
78 | status?: number | undefined;
|
79 | method?: string | undefined;
|
80 | request?: any;
|
81 | response?: any;
|
82 | }
|
83 |
|
84 | interface ServerOptions extends https.ServerOptions {
|
85 | spdy?: {
|
86 | protocols?: Protocol[] | undefined,
|
87 | plain?: boolean | undefined,
|
88 | 'x-forwarded-for'?: boolean | undefined,
|
89 | connection?: {
|
90 | windowSize?: number | undefined,
|
91 | autoSpdy31?: boolean | undefined,
|
92 | } | undefined,
|
93 | } | undefined;
|
94 | }
|
95 | }
|
96 |
|
97 |
|
98 | export namespace socket {
|
99 |
|
100 | interface Socket {}
|
101 | }
|
102 |
|
103 |
|
104 | export type Agent = agent.Agent;
|
105 | export type PlainAgent = agent.PlainAgent;
|
106 | export type AgentOptions = agent.AgentOptions;
|
107 | export type Socket = socket.Socket;
|
108 | export type Server = server.Server;
|
109 | export type IncomingMessage = server.IncomingMessage;
|
110 | export type ServerRequest = server.IncomingMessage;
|
111 | export type ServerResponse = server.ServerResponse;
|
112 | export type PlainServer = server.PlainServer;
|
113 | export type ServerOptions = server.ServerOptions;
|
114 | export function createAgent(base: any, options: AgentOptions): Agent | PlainAgent;
|
115 | export function createAgent(options: AgentOptions): Agent | PlainAgent;
|
116 | export function createServer(
|
117 | base: any,
|
118 | options: ServerOptions,
|
119 | handler: (request: IncomingMessage, response: http.ServerResponse) => void,
|
120 | ): Server;
|
121 | export function createServer(
|
122 | options: ServerOptions,
|
123 | handler: (request: IncomingMessage, response: http.ServerResponse) => void,
|
124 | ): Server;
|
125 | export function createServer(handler: (request: IncomingMessage, response: http.ServerResponse) => void): Server;
|