-
Notifications
You must be signed in to change notification settings - Fork 170
/
Copy pathngx_http_js_module.d.ts
503 lines (489 loc) · 16.5 KB
/
ngx_http_js_module.d.ts
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
/// <reference path="index.d.ts" />
/// <reference path="ngx_core.d.ts" />
interface NginxHTTPArgs {
readonly [prop: string]: string;
}
interface NginxHeadersIn {
// common request headers
readonly 'Accept'?: string;
readonly 'Accept-Charset'?: string;
readonly 'Accept-Encoding'?: string;
readonly 'Accept-Language'?: string;
readonly 'Authorization'?: string;
readonly 'Cache-Control'?: string;
readonly 'Connection'?: string;
readonly 'Content-Length'?: string;
readonly 'Content-Type'?: string;
readonly 'Cookie'?: string;
readonly 'Date'?: string;
readonly 'Expect'?: string;
readonly 'Forwarded'?: string;
readonly 'From'?: string;
readonly 'Host'?: string;
readonly 'If-Match'?: string;
readonly 'If-Modified-Since'?: string;
readonly 'If-None-Match'?: string;
readonly 'If-Range'?: string;
readonly 'If-Unmodified-Since'?: string;
readonly 'Max-Forwards'?: string;
readonly 'Origin'?: string;
readonly 'Pragma'?: string;
readonly 'Proxy-Authorization'?: string;
readonly 'Range'?: string;
readonly 'Referer'?: string;
readonly 'TE'?: string;
readonly 'User-Agent'?: string;
readonly 'Upgrade'?: string;
readonly 'Via'?: string;
readonly 'Warning'?: string;
readonly 'X-Forwarded-For'?: string;
readonly [prop: string]: string | undefined;
}
interface NginxHeadersOut {
// common response headers
'Age'?: string;
'Allow'?: string;
'Alt-Svc'?: string;
'Cache-Control'?: string;
'Connection'?: string;
'Content-Disposition'?: string;
'Content-Encoding'?: string;
'Content-Language'?: string;
'Content-Length'?: string;
'Content-Location'?: string;
'Content-Range'?: string;
'Content-Type'?: string;
'Date'?: string;
'ETag'?: string;
'Expires'?: string;
'Last-Modified'?: string;
'Link'?: string;
'Location'?: string;
'Pragma'?: string;
'Proxy-Authenticate'?: string;
'Retry-After'?: string;
'Server'?: string;
'Trailer'?: string;
'Transfer-Encoding'?: string;
'Upgrade'?: string;
'Vary'?: string;
'Via'?: string;
'Warning'?: string;
'WWW-Authenticate'?: string;
'Set-Cookie'?: string[];
[prop: string]: string | string[] | undefined;
}
interface NginxVariables {
readonly 'ancient_browser'?: string;
readonly 'arg_'?: string;
readonly 'args'?: string;
readonly 'binary_remote_addr'?: string;
readonly 'body_bytes_sent'?: string;
readonly 'bytes_received'?: string;
readonly 'bytes_sent'?: string;
readonly 'connection'?: string;
readonly 'connection_requests'?: string;
readonly 'connections_active'?: string;
readonly 'connections_reading'?: string;
readonly 'connections_waiting'?: string;
readonly 'connections_writing'?: string;
readonly 'content_length'?: string;
readonly 'content_type'?: string;
readonly 'cookie_'?: string;
readonly 'date_gmt'?: string;
readonly 'date_local'?: string;
readonly 'document_root'?: string;
readonly 'document_uri'?: string;
readonly 'fastcgi_path_info'?: string;
readonly 'fastcgi_script_name'?: string;
readonly 'geoip_area_code'?: string;
readonly 'geoip_city'?: string;
readonly 'geoip_city_continent_code'?: string;
readonly 'geoip_city_country_code'?: string;
readonly 'geoip_city_country_code3'?: string;
readonly 'geoip_city_country_name'?: string;
readonly 'geoip_country_code'?: string;
readonly 'geoip_country_code3'?: string;
readonly 'geoip_country_name'?: string;
readonly 'geoip_dma_code'?: string;
readonly 'geoip_latitude'?: string;
readonly 'geoip_longitude'?: string;
readonly 'geoip_org'?: string;
readonly 'geoip_postal_code'?: string;
readonly 'geoip_region'?: string;
readonly 'geoip_region_name'?: string;
readonly 'gzip_ratio'?: string;
readonly 'host'?: string;
readonly 'hostname'?: string;
readonly 'http2'?: string;
readonly 'http_'?: string;
readonly 'https'?: string;
readonly 'invalid_referer'?: string;
readonly 'is_args'?: string;
readonly 'jwt_claim_'?: string;
readonly 'jwt_header_'?: string;
readonly 'limit_conn_status'?: string;
readonly 'limit_rate'?: string;
readonly 'limit_req_status'?: string;
readonly 'memcached_key'?: string;
readonly 'modern_browser'?: string;
readonly 'msec'?: string;
readonly 'msie'?: string;
readonly 'nginx_version'?: string;
readonly 'pid'?: string;
readonly 'pipe'?: string;
readonly 'protocol'?: string;
readonly 'proxy_add_x_forwarded_for'?: string;
readonly 'proxy_host'?: string;
readonly 'proxy_port'?: string;
readonly 'proxy_protocol_addr'?: string;
readonly 'proxy_protocol_port'?: string;
readonly 'proxy_protocol_server_addr'?: string;
readonly 'proxy_protocol_server_port'?: string;
readonly 'query_string'?: string;
readonly 'realip_remote_addr'?: string;
readonly 'realip_remote_port'?: string;
readonly 'realpath_root'?: string;
readonly 'remote_addr'?: string;
readonly 'remote_port'?: string;
readonly 'remote_user'?: string;
readonly 'request'?: string;
readonly 'request_body'?: string;
readonly 'request_body_file'?: string;
readonly 'request_completion'?: string;
readonly 'request_filename'?: string;
readonly 'request_id'?: string;
readonly 'request_length'?: string;
readonly 'request_method'?: string;
readonly 'request_time'?: string;
readonly 'request_uri'?: string;
readonly 'scheme'?: string;
readonly 'secure_link'?: string;
readonly 'secure_link_expires'?: string;
readonly 'sent_http_'?: string;
readonly 'sent_trailer_'?: string;
readonly 'server_addr'?: string;
readonly 'server_name'?: string;
readonly 'server_port'?: string;
readonly 'server_protocol'?: string;
readonly 'session_log_binary_id'?: string;
readonly 'session_log_id'?: string;
readonly 'session_time'?: string;
readonly 'slice_range'?: string;
readonly 'spdy'?: string;
readonly 'spdy_request_priority'?: string;
readonly 'ssl_cipher'?: string;
readonly 'ssl_ciphers'?: string;
readonly 'ssl_client_cert'?: string;
readonly 'ssl_client_escaped_cert'?: string;
readonly 'ssl_client_fingerprint'?: string;
readonly 'ssl_client_i_dn'?: string;
readonly 'ssl_client_i_dn_legacy'?: string;
readonly 'ssl_client_raw_cert'?: string;
readonly 'ssl_client_s_dn'?: string;
readonly 'ssl_client_s_dn_legacy'?: string;
readonly 'ssl_client_serial'?: string;
readonly 'ssl_client_v_end'?: string;
readonly 'ssl_client_v_remain'?: string;
readonly 'ssl_client_v_start'?: string;
readonly 'ssl_client_verify'?: string;
readonly 'ssl_curves'?: string;
readonly 'ssl_early_data'?: string;
readonly 'ssl_preread_alpn_protocols'?: string;
readonly 'ssl_preread_protocol'?: string;
readonly 'ssl_preread_server_name'?: string;
readonly 'ssl_protocol'?: string;
readonly 'ssl_server_name'?: string;
readonly 'ssl_session_id'?: string;
readonly 'ssl_session_reused'?: string;
readonly 'status'?: string;
readonly 'tcpinfo_rtt'?: string;
readonly 'tcpinfo_rttvar'?: string;
readonly 'tcpinfo_snd_cwnd'?: string;
readonly 'tcpinfo_rcv_space'?: string;
readonly 'time_iso8601'?: string;
readonly 'time_local'?: string;
readonly 'uid_got'?: string;
readonly 'uid_reset'?: string;
readonly 'uid_set'?: string;
readonly 'upstream_addr'?: string;
readonly 'upstream_bytes_received'?: string;
readonly 'upstream_bytes_sent'?: string;
readonly 'upstream_cache_status'?: string;
readonly 'upstream_connect_time'?: string;
readonly 'upstream_cookie_'?: string;
readonly 'upstream_first_byte_time'?: string;
readonly 'upstream_header_time'?: string;
readonly 'upstream_http_'?: string;
readonly 'upstream_queue_time'?: string;
readonly 'upstream_response_length'?: string;
readonly 'upstream_response_time'?: string;
readonly 'upstream_session_time'?: string;
readonly 'upstream_status'?: string;
readonly 'upstream_trailer_'?: string;
readonly 'uri'?: string;
[prop: string]: string | undefined;
}
/**
* @since 0.5.0
*/
type NginxRawVariables = {
[K in keyof NginxVariables]: Buffer | undefined;
};
interface NginxSubrequestOptions {
/**
* Arguments string, by default an empty string is used.
*/
args?: string,
/**
* Request body, by default the request body of the parent request object is used.
*/
body?: string,
/**
* HTTP method, by default the GET method is used.
*/
method?: "GET" | "POST" | "OPTIONS" | "HEAD" | "PROPFIND" | "PUT"
| "MKCOL" | "DELETE" | "COPY" | "MOVE" | "PROPPATCH"
| "LOCK" | "PATCH" | "TRACE",
/**
* if true, the created subrequest is a detached subrequest.
* Responses to detached subrequests are ignored.
*/
detached?: boolean
}
interface NginxHTTPSendBufferOptions {
/**
* True if data is a last buffer.
*/
last?: boolean
/**
* True if the buffer should have the flush flag.
*/
flush?: boolean
}
interface NginxHTTPRequest {
/**
* Request arguments object.
*
* Since 0.7.6, duplicate keys are returned as an array, keys are
* case-sensitive, both keys and values are percent-decoded.
* For example, the query string
*
* 'a=1&b=%32&A=3&b=4&B=two%20words'
* is converted to r.args as:
*
* {a: "1", b: ["2", "4"], A: "3", B: "two words"}
*/
readonly args: NginxHTTPArgs;
/**
* After calling this function, next data chunks will be passed to
* the client without calling js_body_filter.
*
* **Warning:** May be called only from the js_body_filter function.
*
* @since 0.5.2
*/
done(): void;
/**
* Writes a string to the error log on the error level of logging.
* @param message Message to log.
*/
error(message: NjsStringOrBuffer): void;
/**
* Finishes sending a response to the client.
*/
finish(): void;
/**
* Incoming headers object.
*/
readonly headersIn: NginxHeadersIn;
/**
* Outgoing headers object.
*/
readonly headersOut: NginxHeadersOut;
/**
* HTTP protocol version.
*/
readonly httpVersion: string;
/**
* Performs an internal redirect to the specified uri.
* If the uri starts with the “@” prefix, it is considered a named location.
* The actual redirect happens after the handler execution is completed.
* Since 0.7.4, the method accepts escaped URIs.
* @param uri Location to redirect to.
*/
internalRedirect(uri: NjsStringOrBuffer): void;
/**
* Writes a string to the error log on the info level of logging.
* @param message Message to log.
*/
log(message: NjsStringOrBuffer): void;
/**
* HTTP method.
*/
readonly method: string;
/**
* Parent for subrequest object.
*/
readonly parent?: NginxHTTPRequest;
/**
* An array of key-value pairs exactly as they were received from the client.
* @since 0.4.1
*/
readonly rawHeadersIn: [NjsFixedSizeArray<2, string>];
/**
* An array of key-value pairs of response headers.
* Header field names are not converted to lower case, duplicate field values are not merged.
* @since 0.4.1
*/
readonly rawHeadersOut: [NjsFixedSizeArray<2, string>];
/**
* Client address.
*/
readonly remoteAddress: string;
/**
* Client request body if it has not been written to a temporary file.
* To ensure that the client request body is in memory, its size should be
* limited by client_max_body_size, and a sufficient buffer size should be set
* using client_body_buffer_size. The property is available only in the js_content directive.
*
* @since 0.5.0
*/
readonly requestBuffer?: Buffer;
/**
* The same as `requestBuffer`, but returns a string.
*
* **Warning:** It may convert bytes invalid in UTF-8 encoding into the replacement character.
*
* @see requestBuffer
* @since 0.5.0
*/
readonly requestText?: string;
/**
* The same as `requestBuffer`, but returns a string.
*
* **Warning:** It may convert bytes invalid in UTF-8 encoding into the replacement character.
*
* @see requestBuffer
* @see requestText
* @deprecated Use `requestText` or `requestBuffer` instead.
*/
readonly requestBody?: string;
/**
* Subrequest response body. The size of response body is limited by
* the subrequest_output_buffer_size directive.
*
* @since 0.5.0
*/
readonly responseBuffer?: Buffer;
/**
* The same as `responseBuffer`, but returns a string.
*
* **Warning:** It may convert bytes invalid in UTF-8 encoding into the replacement character.
*
* @see responseBuffer
*/
readonly responseText?: string;
/**
* The same as `responseBuffer`, but returns a string.
*
* **Warning:** It may convert bytes invalid in UTF-8 encoding into the replacement character.
*
* @see responseBuffer
* @see responseText
* @deprecated Use `responseText` or `responseBuffer` instead.
*/
readonly responseBody?: string;
/**
* Sends the entire response with the specified status to the client.
* It is possible to specify either a redirect URL (for codes 301, 302, 303, 307, and 308)
* or the response body text (for other codes) as the second argument.
* @param status Respose status code.
* @param body Respose body.
*/
return(status: number, body?: NjsStringOrBuffer): void;
/**
* Sends a part of the response body to the client.
*/
send(part: NjsStringOrBuffer): void;
/**
* Adds data to the chain of data chunks to be forwarded to the next body filter.
* The actual forwarding happens later, when the all the data chunks of the current
* chain are processed.
*
* **Warning:** May be called only from the js_body_filter function.
*
* @since 0.5.2
* @param data Data to send.
* @param options Object used to override nginx buffer flags derived from
* an incoming data chunk buffer.
*/
sendBuffer(data: NjsStringOrBuffer, options?: NginxHTTPSendBufferOptions): void;
/**
* Sends the HTTP headers to the client.
*/
sendHeader(): void;
/**
* Respose status code.
*/
status: number;
/**
* Creates a subrequest with the given uri and options.
* A subrequest shares its input headers with the client request.
* To send headers different from original headers to a proxied server,
* the proxy_set_header directive can be used. To send a completely new
* set of headers to a proxied server, the proxy_pass_request_headers directive can be used.
* @param uri Subrequest location.
* @param options Subrequest options.
* @param callback Completion callback.
*/
subrequest(uri: NjsStringOrBuffer, options: NginxSubrequestOptions & { detached: true }): void;
subrequest(uri: NjsStringOrBuffer, options?: NginxSubrequestOptions | string): Promise<NginxHTTPRequest>;
subrequest(uri: NjsStringOrBuffer, options: NginxSubrequestOptions & { detached?: false } | string,
callback:(reply:NginxHTTPRequest) => void): void;
subrequest(uri: NjsStringOrBuffer, callback:(reply:NginxHTTPRequest) => void): void;
/**
* Current URI in request, normalized.
*/
readonly uri: string;
/**
* nginx variables as Buffers.
*
* @since 0.5.0
* @see variables
*/
readonly rawVariables: NginxRawVariables;
/**
* nginx variables as strings.
*
* **Warning:** Bytes invalid in UTF-8 encoding may be converted into the replacement character.
*
* @see rawVariables
*/
readonly variables: NginxVariables;
/**
* Writes a string to the error log on the warn level of logging.
* @param message Message to log.
*/
warn(message: NjsStringOrBuffer): void;
}
/**
* NginxPeriodicSession object is available as the first argument in the js_periodic handler.
* @since 0.8.1
*/
interface NginxPeriodicSession {
/**
* nginx variables as Buffers.
*
* @see variables
*/
readonly rawVariables: NginxRawVariables;
/**
* nginx variables as strings.
*
* **Warning:** Bytes invalid in UTF-8 encoding may be converted into the replacement character.
*
* @see rawVariables
*/
readonly variables: NginxVariables;
}