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