comparison xml/en/docs/http/ngx_http_js_module.xml @ 2675:893cd7724c8c

Documented the "r" argument for js_body_filter.
author Yaroslav Zhuravlev <yar@nginx.com>
date Tue, 09 Mar 2021 18:44:56 +0000
parents 9e39e64bff84
children 8751cab1d562
comparison
equal deleted inserted replaced
2674:e87c0ffc3492 2675:893cd7724c8c
7 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd"> 7 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">
8 8
9 <module name="Module ngx_http_js_module" 9 <module name="Module ngx_http_js_module"
10 link="/en/docs/http/ngx_http_js_module.html" 10 link="/en/docs/http/ngx_http_js_module.html"
11 lang="en" 11 lang="en"
12 rev="24"> 12 rev="25">
13 13
14 <section id="summary"> 14 <section id="summary">
15 15
16 <para> 16 <para>
17 The <literal>ngx_http_js_module</literal> module is used to implement 17 The <literal>ngx_http_js_module</literal> module is used to implement
130 Sets an njs function as a response body filter. 130 Sets an njs function as a response body filter.
131 The filter function is called for each data chunk of a response body 131 The filter function is called for each data chunk of a response body
132 with the following arguments: 132 with the following arguments:
133 133
134 <list type="tag"> 134 <list type="tag">
135 <tag-name><literal>r</literal></tag-name>
136 <tag-desc>
137 the <link doc="../njs/reference.xml" id="http">HTTP request</link> object
138 </tag-desc>
139
135 <tag-name><literal>data</literal></tag-name> 140 <tag-name><literal>data</literal></tag-name>
136 <tag-desc> 141 <tag-desc>
137 the incoming data chunk, 142 the incoming data chunk,
138 may be a string or Buffer 143 may be a string or Buffer
139 depending on the <literal>buffer_type</literal> value, 144 depending on the <literal>buffer_type</literal> value,
159 The filter function can pass its own modified version 164 The filter function can pass its own modified version
160 of the input data chunk to the next body filter by calling 165 of the input data chunk to the next body filter by calling
161 <link doc="../njs/reference.xml" id="r_sendbuffer"><literal>r.sendBuffer()</literal></link>. 166 <link doc="../njs/reference.xml" id="r_sendbuffer"><literal>r.sendBuffer()</literal></link>.
162 For example, to transform all the lowercase letters in the response body: 167 For example, to transform all the lowercase letters in the response body:
163 <example> 168 <example>
164 function filter(data, flags) { 169 function filter(r, data, flags) {
165 r.sendBuffer(data.toLowerCase(), flags); 170 r.sendBuffer(data.toLowerCase(), flags);
166 } 171 }
167 </example> 172 </example>
168 To stop filtering (following data chunks will be passed to client 173 To stop filtering (following data chunks will be passed to client
169 without calling <literal>js_body_filter</literal>), 174 without calling <literal>js_body_filter</literal>),