1 |
|
2 |
|
3 | import * as http from "http";
|
4 | import * as https from "https";
|
5 |
|
6 |
|
7 | export namespace agent {
|
8 | class Agent extends https.Agent {}
|
9 | class PlainAgent extends http.Agent {}
|
10 | function create(base: any, options: AgentOptions): Agent | PlainAgent;
|
11 |
|
12 | interface AgentOptions extends https.AgentOptions {
|
13 | port?: number | undefined;
|
14 | spdy?: {
|
15 | plain?: boolean | undefined;
|
16 | ssl?: boolean | undefined;
|
17 | "x-forwarded-for"?: string | undefined;
|
18 | protocol?: string | undefined;
|
19 | protocols?: string[] | undefined;
|
20 | } | undefined;
|
21 | }
|
22 | }
|
23 |
|
24 |
|
25 | export interface Handle {
|
26 | create(options: object, stream: any, socket: Socket): Handle;
|
27 | getStream(callback?: (stream: any) => void): any;
|
28 | assignSocket(socket: Socket, options: object): void;
|
29 | assignClientRequest(req: any): void;
|
30 | assignRequest(req: any): void;
|
31 | assignResponse(res: any): void;
|
32 | emitRequest(): void;
|
33 | emitResponse(status: any, headers: any): void;
|
34 | }
|
35 |
|
36 |
|
37 | export namespace request {
|
38 | function onNewListener(type: string): void;
|
39 | }
|
40 |
|
41 |
|
42 | export namespace response {
|
43 | function writeHead(statusCode: number, reason: string, obj: object): void;
|
44 | function writeHead(statusCode: number, obj: object): void;
|
45 | function end(data: any, encoding: string, callback: () => void): void;
|
46 | }
|
47 |
|
48 |
|
49 | export namespace server {
|
50 | type Server = https.Server;
|
51 | type PlainServer = http.Server;
|
52 | type IncomingMessage = http.IncomingMessage;
|
53 | interface ServerResponse extends http.ServerResponse {
|
54 | push(filename: string, options: PushOptions): any;
|
55 | }
|
56 | function create(
|
57 | base: any,
|
58 | options: https.ServerOptions,
|
59 | handler: (request: IncomingMessage, response: ServerResponse | http.ServerResponse) => void,
|
60 | ): Server;
|
61 | function create(
|
62 | options: https.ServerOptions,
|
63 | handler: (request: IncomingMessage, response: http.ServerResponse) => void,
|
64 | ): Server;
|
65 | function create(
|
66 | handler: (request: IncomingMessage, response: ServerResponse | http.ServerResponse) => void,
|
67 | ): 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;
|