changeset 2546:6093e9f3615e

Documented rawHeadersIn and rawHeadersOut in njs.
author Yaroslav Zhuravlev <yar@nginx.com>
date Tue, 19 May 2020 15:05:49 +0100
parents dca5a7053a6c
children baf8cbfa3df1
files xml/en/docs/njs/reference.xml xml/ru/docs/njs/reference.xml
diffstat 2 files changed, 84 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/xml/en/docs/njs/reference.xml
+++ b/xml/en/docs/njs/reference.xml
@@ -168,6 +168,48 @@ references the parent request object
 client address, read-only
 </tag-desc>
 
+<tag-name id="r_raw_headers_in"><literal>r.rawHeadersIn{}</literal></tag-name>
+<tag-desc>
+returns an array of key-value pairs
+exactly as they were received from the client
+(<link doc="changes.xml" id="njs0.4.1">0.4.1</link>).
+<para>
+For example, with the following request headers:
+<example>
+Host: localhost
+Foo:  bar
+foo:  bar2
+</example>
+the output of <literal>r.rawHeadersIn</literal> will be:
+<example>
+[
+    ['Host', 'localhost'],
+    ['Foo', 'bar'],
+    ['foo', 'bar2']
+]
+</example>
+All <literal>foo</literal> headers
+can be collected with the syntax:
+<example>
+r.rawHeadersIn.filter(v=>v[0].toLowerCase() == 'foo').map(v=>v[1])
+</example>
+the output will be:
+<example>
+['bar', 'bar2']
+</example>
+Header field names are not converted to lower case,
+duplicate field values are not merged.
+</para>
+</tag-desc>
+
+<tag-name id="r_raw_headers_out"><literal>r.rawHeadersOut{}</literal></tag-name>
+<tag-desc>
+returns an array of key-value pairs of response headers
+(<link doc="changes.xml" id="njs0.4.1">0.4.1</link>).
+Header field names are not converted to lower case,
+duplicate field values are not merged.
+</tag-desc>
+
 <tag-name id="r_request_body"><literal>r.requestBody</literal></tag-name>
 <tag-desc>
 returns the client request body if it has not been
--- a/xml/ru/docs/njs/reference.xml
+++ b/xml/ru/docs/njs/reference.xml
@@ -170,6 +170,48 @@ HTTP метод, только чтение
 адрес клиента, только чтение
 </tag-desc>
 
+<tag-name id="r_raw_headers_in"><literal>r.rawHeadersIn{}</literal></tag-name>
+<tag-desc>
+возвращает массив пар ключей и значений
+таким же, каким он был получен от клиента
+(<link doc="changes.xml" id="njs0.4.1">0.4.1</link>).
+<para>
+Например для следующих заголовков запроса:
+<example>
+Host: localhost
+Foo:  bar
+foo:  bar2
+</example>
+результат <literal>r.rawHeadersIn</literal>:
+<example>
+[
+    ['Host', 'localhost'],
+    ['Foo', 'bar'],
+    ['foo', 'bar2']
+]
+</example>
+Значения полей всех заголовков <literal>foo</literal>
+можно получить при помощи синтаксиса:
+<example>
+r.rawHeadersIn.filter(v=>v[0].toLowerCase() == 'foo').map(v=>v[1])
+</example>
+результат:
+<example>
+['bar', 'bar2']
+</example>
+Имена полей заголовков не приводятся к нижнему регистру,
+дубликаты значений поля не объединяются.
+</para>
+</tag-desc>
+
+<tag-name id="r_raw_headers_out"><literal>r.rawHeadersOut{}</literal></tag-name>
+<tag-desc>
+возвращает массив пар ключей и значений заголовков ответа
+(<link doc="changes.xml" id="njs0.4.1">0.4.1</link>).
+Имена полей заголовков не приводятся к нижнему регистру,
+дубликаты значений поля не объединяются.
+</tag-desc>
+
 <tag-name id="r_request_body"><literal>r.requestBody</literal></tag-name>
 <tag-desc>
 возвращает тело запроса клиента, если оно не было