@types/node 10.12.17 → 10.12.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- node/README.md +3 -3
- node/assert.d.ts +52 -0
- node/async_hooks.d.ts +144 -0
- node/buffer.d.ts +6 -0
- node/child_process.d.ts +358 -0
- node/cluster.d.ts +261 -0
- node/console.d.ts +3 -0
- node/constants.d.ts +279 -0
- node/crypto.d.ts +369 -0
- node/dgram.d.ts +97 -0
- node/dns.d.ts +292 -0
- node/domain.d.ts +16 -0
- node/events.d.ts +29 -0
- node/fs.d.ts +2272 -0
- node/globals.d.ts +1031 -0
- node/http.d.ts +247 -0
- node/http2.d.ts +861 -0
- node/https.d.ts +37 -0
- node/index.d.ts +41 -9183
- node/inspector.d.ts +0 -1
- node/module.d.ts +3 -0
- node/net.d.ts +251 -0
- node/os.d.ts +192 -0
- node/package.json +7 -2
- node/path.d.ts +159 -0
- node/perf_hooks.d.ts +241 -0
- node/process.d.ts +3 -0
- node/punycode.d.ts +12 -0
- node/querystring.d.ts +17 -0
- node/readline.d.ts +135 -0
- node/repl.d.ts +372 -0
- node/stream.d.ts +294 -0
- node/string_decoder.d.ts +9 -0
- node/timers.d.ts +16 -0
- node/tls.d.ts +371 -0
- node/trace_events.d.ts +61 -0
- node/tty.d.ts +15 -0
- node/url.d.ts +104 -0
- node/util.d.ts +173 -0
- node/v8.d.ts +28 -0
- node/vm.d.ts +64 -0
- node/worker_threads.d.ts +124 -0
- node/zlib.d.ts +141 -0
node/http.d.ts
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
declare module "http" {
|
|
2
|
+
import * as events from "events";
|
|
3
|
+
import * as net from "net";
|
|
4
|
+
import * as stream from "stream";
|
|
5
|
+
import { URL } from "url";
|
|
6
|
+
|
|
7
|
+
// incoming headers will never contain number
|
|
8
|
+
interface IncomingHttpHeaders {
|
|
9
|
+
'accept'?: string;
|
|
10
|
+
'access-control-allow-origin'?: string;
|
|
11
|
+
'access-control-allow-credentials'?: string;
|
|
12
|
+
'access-control-expose-headers'?: string;
|
|
13
|
+
'access-control-max-age'?: string;
|
|
14
|
+
'access-control-allow-methods'?: string;
|
|
15
|
+
'access-control-allow-headers'?: string;
|
|
16
|
+
'accept-patch'?: string;
|
|
17
|
+
'accept-ranges'?: string;
|
|
18
|
+
'age'?: string;
|
|
19
|
+
'allow'?: string;
|
|
20
|
+
'alt-svc'?: string;
|
|
21
|
+
'authorization'?: string;
|
|
22
|
+
'cache-control'?: string;
|
|
23
|
+
'connection'?: string;
|
|
24
|
+
'content-disposition'?: string;
|
|
25
|
+
'content-encoding'?: string;
|
|
26
|
+
'content-language'?: string;
|
|
27
|
+
'content-length'?: string;
|
|
28
|
+
'content-location'?: string;
|
|
29
|
+
'content-range'?: string;
|
|
30
|
+
'content-type'?: string;
|
|
31
|
+
'cookie'?: string;
|
|
32
|
+
'date'?: string;
|
|
33
|
+
'expect'?: string;
|
|
34
|
+
'expires'?: string;
|
|
35
|
+
'forwarded'?: string;
|
|
36
|
+
'from'?: string;
|
|
37
|
+
'host'?: string;
|
|
38
|
+
'if-match'?: string;
|
|
39
|
+
'if-modified-since'?: string;
|
|
40
|
+
'if-none-match'?: string;
|
|
41
|
+
'if-unmodified-since'?: string;
|
|
42
|
+
'last-modified'?: string;
|
|
43
|
+
'location'?: string;
|
|
44
|
+
'pragma'?: string;
|
|
45
|
+
'proxy-authenticate'?: string;
|
|
46
|
+
'proxy-authorization'?: string;
|
|
47
|
+
'public-key-pins'?: string;
|
|
48
|
+
'range'?: string;
|
|
49
|
+
'referer'?: string;
|
|
50
|
+
'retry-after'?: string;
|
|
51
|
+
'set-cookie'?: string[];
|
|
52
|
+
'strict-transport-security'?: string;
|
|
53
|
+
'trailer'?: string;
|
|
54
|
+
'transfer-encoding'?: string;
|
|
55
|
+
'tk'?: string;
|
|
56
|
+
'upgrade'?: string;
|
|
57
|
+
'user-agent'?: string;
|
|
58
|
+
'vary'?: string;
|
|
59
|
+
'via'?: string;
|
|
60
|
+
'warning'?: string;
|
|
61
|
+
'www-authenticate'?: string;
|
|
62
|
+
[header: string]: string | string[] | undefined;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// outgoing headers allows numbers (as they are converted internally to strings)
|
|
66
|
+
interface OutgoingHttpHeaders {
|
|
67
|
+
[header: string]: number | string | string[] | undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface ClientRequestArgs {
|
|
71
|
+
protocol?: string;
|
|
72
|
+
host?: string;
|
|
73
|
+
hostname?: string;
|
|
74
|
+
family?: number;
|
|
75
|
+
port?: number | string;
|
|
76
|
+
defaultPort?: number | string;
|
|
77
|
+
localAddress?: string;
|
|
78
|
+
socketPath?: string;
|
|
79
|
+
method?: string;
|
|
80
|
+
path?: string;
|
|
81
|
+
headers?: OutgoingHttpHeaders;
|
|
82
|
+
auth?: string;
|
|
83
|
+
agent?: Agent | boolean;
|
|
84
|
+
_defaultAgent?: Agent;
|
|
85
|
+
timeout?: number;
|
|
86
|
+
setHost?: boolean;
|
|
87
|
+
// https://github.com/nodejs/node/blob/master/lib/_http_client.js#L278
|
|
88
|
+
createConnection?: (options: ClientRequestArgs, oncreate: (err: Error, socket: net.Socket) => void) => net.Socket;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
class Server extends net.Server {
|
|
92
|
+
constructor(requestListener?: (req: IncomingMessage, res: ServerResponse) => void);
|
|
93
|
+
|
|
94
|
+
setTimeout(msecs?: number, callback?: () => void): this;
|
|
95
|
+
setTimeout(callback: () => void): this;
|
|
96
|
+
maxHeadersCount: number;
|
|
97
|
+
timeout: number;
|
|
98
|
+
keepAliveTimeout: number;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// https://github.com/nodejs/node/blob/master/lib/_http_outgoing.js
|
|
102
|
+
class OutgoingMessage extends stream.Writable {
|
|
103
|
+
upgrading: boolean;
|
|
104
|
+
chunkedEncoding: boolean;
|
|
105
|
+
shouldKeepAlive: boolean;
|
|
106
|
+
useChunkedEncodingByDefault: boolean;
|
|
107
|
+
sendDate: boolean;
|
|
108
|
+
finished: boolean;
|
|
109
|
+
headersSent: boolean;
|
|
110
|
+
connection: net.Socket;
|
|
111
|
+
|
|
112
|
+
constructor();
|
|
113
|
+
|
|
114
|
+
setTimeout(msecs: number, callback?: () => void): this;
|
|
115
|
+
setHeader(name: string, value: number | string | string[]): void;
|
|
116
|
+
getHeader(name: string): number | string | string[] | undefined;
|
|
117
|
+
getHeaders(): OutgoingHttpHeaders;
|
|
118
|
+
getHeaderNames(): string[];
|
|
119
|
+
hasHeader(name: string): boolean;
|
|
120
|
+
removeHeader(name: string): void;
|
|
121
|
+
addTrailers(headers: OutgoingHttpHeaders | Array<[string, string]>): void;
|
|
122
|
+
flushHeaders(): void;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// https://github.com/nodejs/node/blob/master/lib/_http_server.js#L108-L256
|
|
126
|
+
class ServerResponse extends OutgoingMessage {
|
|
127
|
+
statusCode: number;
|
|
128
|
+
statusMessage: string;
|
|
129
|
+
|
|
130
|
+
constructor(req: IncomingMessage);
|
|
131
|
+
|
|
132
|
+
assignSocket(socket: net.Socket): void;
|
|
133
|
+
detachSocket(socket: net.Socket): void;
|
|
134
|
+
// https://github.com/nodejs/node/blob/master/test/parallel/test-http-write-callbacks.js#L53
|
|
135
|
+
// no args in writeContinue callback
|
|
136
|
+
writeContinue(callback?: () => void): void;
|
|
137
|
+
writeHead(statusCode: number, reasonPhrase?: string, headers?: OutgoingHttpHeaders): void;
|
|
138
|
+
writeHead(statusCode: number, headers?: OutgoingHttpHeaders): void;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// https://github.com/nodejs/node/blob/master/lib/_http_client.js#L77
|
|
142
|
+
class ClientRequest extends OutgoingMessage {
|
|
143
|
+
connection: net.Socket;
|
|
144
|
+
socket: net.Socket;
|
|
145
|
+
aborted: number;
|
|
146
|
+
|
|
147
|
+
constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void);
|
|
148
|
+
|
|
149
|
+
abort(): void;
|
|
150
|
+
onSocket(socket: net.Socket): void;
|
|
151
|
+
setTimeout(timeout: number, callback?: () => void): this;
|
|
152
|
+
setNoDelay(noDelay?: boolean): void;
|
|
153
|
+
setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
class IncomingMessage extends stream.Readable {
|
|
157
|
+
constructor(socket: net.Socket);
|
|
158
|
+
|
|
159
|
+
httpVersion: string;
|
|
160
|
+
httpVersionMajor: number;
|
|
161
|
+
httpVersionMinor: number;
|
|
162
|
+
connection: net.Socket;
|
|
163
|
+
headers: IncomingHttpHeaders;
|
|
164
|
+
rawHeaders: string[];
|
|
165
|
+
trailers: { [key: string]: string | undefined };
|
|
166
|
+
rawTrailers: string[];
|
|
167
|
+
setTimeout(msecs: number, callback: () => void): this;
|
|
168
|
+
/**
|
|
169
|
+
* Only valid for request obtained from http.Server.
|
|
170
|
+
*/
|
|
171
|
+
method?: string;
|
|
172
|
+
/**
|
|
173
|
+
* Only valid for request obtained from http.Server.
|
|
174
|
+
*/
|
|
175
|
+
url?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Only valid for response obtained from http.ClientRequest.
|
|
178
|
+
*/
|
|
179
|
+
statusCode?: number;
|
|
180
|
+
/**
|
|
181
|
+
* Only valid for response obtained from http.ClientRequest.
|
|
182
|
+
*/
|
|
183
|
+
statusMessage?: string;
|
|
184
|
+
socket: net.Socket;
|
|
185
|
+
destroy(error?: Error): void;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
interface AgentOptions {
|
|
189
|
+
/**
|
|
190
|
+
* Keep sockets around in a pool to be used by other requests in the future. Default = false
|
|
191
|
+
*/
|
|
192
|
+
keepAlive?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000.
|
|
195
|
+
* Only relevant if keepAlive is set to true.
|
|
196
|
+
*/
|
|
197
|
+
keepAliveMsecs?: number;
|
|
198
|
+
/**
|
|
199
|
+
* Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity
|
|
200
|
+
*/
|
|
201
|
+
maxSockets?: number;
|
|
202
|
+
/**
|
|
203
|
+
* Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256.
|
|
204
|
+
*/
|
|
205
|
+
maxFreeSockets?: number;
|
|
206
|
+
/**
|
|
207
|
+
* Socket timeout in milliseconds. This will set the timeout after the socket is connected.
|
|
208
|
+
*/
|
|
209
|
+
timeout?: number;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
class Agent {
|
|
213
|
+
maxFreeSockets: number;
|
|
214
|
+
maxSockets: number;
|
|
215
|
+
sockets: any;
|
|
216
|
+
requests: any;
|
|
217
|
+
|
|
218
|
+
constructor(opts?: AgentOptions);
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Destroy any sockets that are currently in use by the agent.
|
|
222
|
+
* It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled,
|
|
223
|
+
* then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise,
|
|
224
|
+
* sockets may hang open for quite a long time before the server terminates them.
|
|
225
|
+
*/
|
|
226
|
+
destroy(): void;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const METHODS: string[];
|
|
230
|
+
|
|
231
|
+
const STATUS_CODES: {
|
|
232
|
+
[errorCode: number]: string | undefined;
|
|
233
|
+
[errorCode: string]: string | undefined;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) => void): Server;
|
|
237
|
+
function createClient(port?: number, host?: string): any;
|
|
238
|
+
|
|
239
|
+
// although RequestOptions are passed as ClientRequestArgs to ClientRequest directly,
|
|
240
|
+
// create interface RequestOptions would make the naming more clear to developers
|
|
241
|
+
interface RequestOptions extends ClientRequestArgs { }
|
|
242
|
+
function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
|
|
243
|
+
function request(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
|
|
244
|
+
function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
|
|
245
|
+
function get(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
|
|
246
|
+
let globalAgent: Agent;
|
|
247
|
+
}
|