# HG changeset patch # User Yaroslav Zhuravlev # Date 1589897149 -3600 # Node ID 6093e9f3615eb5071f4255df15995892204b88d8 # Parent dca5a7053a6c8964b6d2dd80667fbd142c62ef70 Documented rawHeadersIn and rawHeadersOut in njs. 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 @@ -168,6 +168,48 @@ references the parent request object client address, read-only +r.rawHeadersIn{} + +returns an array of key-value pairs +exactly as they were received from the client +(0.4.1). + +For example, with the following request headers: + +Host: localhost +Foo: bar +foo: bar2 + +the output of r.rawHeadersIn will be: + +[ + ['Host', 'localhost'], + ['Foo', 'bar'], + ['foo', 'bar2'] +] + +All foo headers +can be collected with the syntax: + +r.rawHeadersIn.filter(v=>v[0].toLowerCase() == 'foo').map(v=>v[1]) + +the output will be: + +['bar', 'bar2'] + +Header field names are not converted to lower case, +duplicate field values are not merged. + + + +r.rawHeadersOut{} + +returns an array of key-value pairs of response headers +(0.4.1). +Header field names are not converted to lower case, +duplicate field values are not merged. + + r.requestBody returns the client request body if it has not been 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 @@ -170,6 +170,48 @@ HTTP метод, только чтение адрес клиента, только чтение +r.rawHeadersIn{} + +возвращает массив пар ключей и значений +таким же, каким он был получен от клиента +(0.4.1). + +Например для следующих заголовков запроса: + +Host: localhost +Foo: bar +foo: bar2 + +результат r.rawHeadersIn: + +[ + ['Host', 'localhost'], + ['Foo', 'bar'], + ['foo', 'bar2'] +] + +Значения полей всех заголовков foo +можно получить при помощи синтаксиса: + +r.rawHeadersIn.filter(v=>v[0].toLowerCase() == 'foo').map(v=>v[1]) + +результат: + +['bar', 'bar2'] + +Имена полей заголовков не приводятся к нижнему регистру, +дубликаты значений поля не объединяются. + + + +r.rawHeadersOut{} + +возвращает массив пар ключей и значений заголовков ответа +(0.4.1). +Имена полей заголовков не приводятся к нижнему регистру, +дубликаты значений поля не объединяются. + + r.requestBody возвращает тело запроса клиента, если оно не было