# HG changeset patch # User Yaroslav Zhuravlev # Date 1587643063 -3600 # Node ID 423d813dc8bb66ac893f89a832815aa551d2f928 # Parent 9c8a89d3876fd6146954e177e95b0fb394a78952 Documented support for multi-value headers in r.headersOut. diff --git a/xml/en/docs/njs/reference.xml b/xml/en/docs/njs/reference.xml --- a/xml/en/docs/njs/reference.xml +++ b/xml/en/docs/njs/reference.xml @@ -9,7 +9,7 @@
+ rev="39">
@@ -75,9 +75,47 @@ should be used. outgoing headers object, writable. -For example, the Foo header -can be accessed with the syntax headersOut.foo -or headersOut['Foo'] +The
Foo
response header +can be accessed with the syntax: +headersOut.foo or headersOut['Foo']. +
+ + +Field values of multi-value response headers +(0.4.0) +can be set with the syntax: + +r.headersOut[‘Foo’] = [‘a’, ‘b’] + +where the output will be: + +Foo: a +Foo: b + +All previous field values of the
Foo
response header +will be deleted. +
+ + +For standard response headers +that accept only a single field value such as +
Content-Type
, +only the last element of the array will take effect. +Duplicate field values in +
Age
, +
Content-Encoding
, +
Content-Length
, +
Content-Type
, +
ETag
, +
Expires
, +
Last-Modified
, +
Location
, +
Retry-After
+response headers are ignored. +All other duplicate field values of the response header +are joined together with comma “,”. +Field values of the
Set-Cookie
response header +are always returned as an array.
diff --git a/xml/ru/docs/njs/reference.xml b/xml/ru/docs/njs/reference.xml --- a/xml/ru/docs/njs/reference.xml +++ b/xml/ru/docs/njs/reference.xml @@ -76,9 +76,47 @@ объект исходящих заголовков, доступно для записи. -Например, доступ к заголовку Foo -можно получить при помощи синтаксиса headersOut.foo -или headersOut['Foo'] +Доступ к заголовку ответа Foo +можно получить при помощи синтаксиса: +headersOut.foo или headersOut['Foo'] + + + +Значения полей многозначных заголовков ответа +(0.4.0) +можно задать при помощи синтаксиса: + +r.headersOut[‘Foo’] = [‘a’, ‘b’] + +результат: + +Foo: a +Foo: b + +Все предыдущие значения поля заголовка ответа
Foo
+будут удалены. +
+ + +В стандартных заголовках ответа, +поля которых могут принимать только одно значение, например +
Content-Type
, +учитывается только последний элемент массива. +Дубликаты значений поля в заголовках ответа +
Age
, +
Content-Encoding
, +
Content-Length
, +
Content-Type
, +
ETag
, +
Expires
, +
Last-Modified
, +
Location
, +
Retry-After
+игнорируются. +Все другие дубликаты значений поля заголовка ответа +соединяются при помощи запятой (“,”). +Значения поля в заголовке ответа
Set-Cookie
+всегда возвращаются в виде массива.