From 9bd25114f56570ce0614f70e62e737ee6c342307 Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Thu, 9 Feb 2023 18:34:51 -0800 Subject: [PATCH] Types: added forgotten r.rawHeadersIn and r.rawHeadersOut description. --- test/ts/test.ts | 2 ++ ts/ngx_http_js_module.d.ts | 11 +++++++++++ ts/njs_core.d.ts | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/test/ts/test.ts b/test/ts/test.ts index ddbb495e..b7464163 100644 --- a/test/ts/test.ts +++ b/test/ts/test.ts @@ -45,6 +45,8 @@ async function http_module(r: NginxHTTPRequest) { r.headersOut['Set-Cookie'] = ['aaa', 'bbb']; r.headersOut['Foo'] = ['aaa', 'bbb']; + let values: Array = r.rawHeadersIn.filter(v=>v[0].toLowerCase() == 'foo').map(v=>v[1]); + // r.log r.log(bs); diff --git a/ts/ngx_http_js_module.d.ts b/ts/ngx_http_js_module.d.ts index 7afd1308..811d2cb5 100644 --- a/ts/ngx_http_js_module.d.ts +++ b/ts/ngx_http_js_module.d.ts @@ -338,6 +338,17 @@ interface NginxHTTPRequest { * 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, NjsStringLike>]; + /** + * 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, NjsStringLike>]; /** * Client address. */ diff --git a/ts/njs_core.d.ts b/ts/njs_core.d.ts index 5f8dbc68..22af1e92 100644 --- a/ts/njs_core.d.ts +++ b/ts/njs_core.d.ts @@ -1,5 +1,11 @@ type BufferEncoding = "utf8" | "hex" | "base64" | "base64url"; +type NjsFixedSizeArray = N extends 0 ? never[] : { + 0: T; + length: N; +} & ReadonlyArray; + + interface StringConstructor { /** * Creates a byte string from an encoded string. -- 2.47.3