annotate xml/en/docs/http/ngx_http_js_module.xml @ 2149:6df1a86a60b8

Added new njs HTTP properties and methods.
author Roman Arutyunyan <arut@nginx.com>
date Fri, 06 Apr 2018 20:34:26 +0300
parents ca7568f67dee
children cd4889fdcfa4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
1 <?xml version="1.0"?>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
2
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
3 <!--
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
4 Copyright (C) Nginx, Inc.
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
5 -->
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
6
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
7 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
8
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
9 <module name="Module ngx_http_js_module"
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
10 link="/en/docs/http/ngx_http_js_module.html"
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
11 lang="en"
2149
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
12 rev="10">
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
13
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
14 <section id="summary">
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
15
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
16 <para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
17 The <literal>ngx_http_js_module</literal> module is used to implement
1844
f56626ce9c40 Changed JavaScript to nginScript.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1840
diff changeset
18 location and variable handlers
2128
59a3cc84f507 Renamed nginScript to njs
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2026
diff changeset
19 in <link doc="../njs_about.xml">njs</link> —
1844
f56626ce9c40 Changed JavaScript to nginScript.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1840
diff changeset
20 a subset of the JavaScript language.
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
21 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
22
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
23 <para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
24 This module is not built by default, it should be compiled with
2128
59a3cc84f507 Renamed nginScript to njs
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2026
diff changeset
25 the njs module using the
2026
af51ec6b5489 Fixed typos in njs configure string examples.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1942
diff changeset
26 <literal>--add-module</literal> configuration parameter:
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
27 <example>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
28 ./configure --add-module=<value>path-to-njs</value>/nginx
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
29 </example>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
30 The <link url="http://hg.nginx.org/njs">repository</link>
2128
59a3cc84f507 Renamed nginScript to njs
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2026
diff changeset
31 with the njs module can be cloned with the following command
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
32 (requires <link url="https://www.mercurial-scm.org">Mercurial</link> client):
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
33 <example>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
34 hg clone http://hg.nginx.org/njs
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
35 </example>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
36 This module can also be built as
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
37 <link doc="../ngx_core_module.xml" id="load_module">dynamic</link>:
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
38 <example>
2026
af51ec6b5489 Fixed typos in njs configure string examples.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1942
diff changeset
39 ./configure --add-dynamic-module=<value>path-to-njs</value>/nginx
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
40 </example>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
41 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
42
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
43 </section>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
44
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
45
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
46 <section id="example" name="Example Configuration">
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
47
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
48 <para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
49 <example>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
50 js_include http.js;
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
51
1858
36cbfff92c6d Restricted context of js_set directive to http and stream only.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1853
diff changeset
52 js_set $foo foo;
36cbfff92c6d Restricted context of js_set directive to http and stream only.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1853
diff changeset
53 js_set $summary summary;
36cbfff92c6d Restricted context of js_set directive to http and stream only.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1853
diff changeset
54
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
55 server {
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
56 listen 8000;
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
57
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
58 location / {
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
59 add_header X-Foo $foo;
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
60 js_content baz;
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
61 }
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
62
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
63 location /summary {
1858
36cbfff92c6d Restricted context of js_set directive to http and stream only.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1853
diff changeset
64 return 200 $summary;
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
65 }
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
66 }
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
67 </example>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
68 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
69
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
70 <para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
71 The <path>http.js</path> file:
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
72 <example>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
73 function foo(req, res) {
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
74 req.log("hello from foo() handler");
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
75 return "foo";
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
76 }
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
77
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
78 function summary(req, res) {
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
79 var a, s, h;
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
80
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
81 s = "JS summary\n\n";
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
82
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
83 s += "Method: " + req.method + "\n";
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
84 s += "HTTP version: " + req.httpVersion + "\n";
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
85 s += "Host: " + req.headers.host + "\n";
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
86 s += "Remote Address: " + req.remoteAddress + "\n";
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
87 s += "URI: " + req.uri + "\n";
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
88
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
89 s += "Headers:\n";
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
90 for (h in req.headers) {
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
91 s += " header '" + h + "' is '" + req.headers[h] + "'\n";
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
92 }
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
93
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
94 s += "Args:\n";
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
95 for (a in req.args) {
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
96 s += " arg '" + a + "' is '" + req.args[a] + "'\n";
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
97 }
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
98
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
99 return s;
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
100 }
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
101
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
102 function baz(req, res) {
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
103 res.headers.foo = 1234;
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
104 res.status = 200;
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
105 res.contentType = "text/plain; charset=utf-8";
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
106 res.contentLength = 15;
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
107 res.sendHeader();
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
108 res.send("nginx");
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
109 res.send("java");
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
110 res.send("script");
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
111
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
112 res.finish();
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
113 }
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
114 </example>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
115 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
116
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
117 </section>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
118
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
119
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
120 <section id="directives" name="Directives">
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
121
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
122 <directive name="js_content">
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
123 <syntax><value>function</value></syntax>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
124 <default/>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
125 <context>location</context>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
126 <context>limit_except</context>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
127
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
128 <para>
2128
59a3cc84f507 Renamed nginScript to njs
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2026
diff changeset
129 Sets an njs function as a location content handler.
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
130 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
131
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
132 </directive>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
133
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
134
2142
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
135 <directive name="js_include">
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
136 <syntax><value>file</value></syntax>
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
137 <default/>
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
138 <context>http</context>
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
139
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
140 <para>
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
141 Specifies a file that implements location and variable handlers in njs.
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
142 </para>
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
143
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
144 </directive>
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
145
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
146
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
147 <directive name="js_set">
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
148 <syntax>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
149 <value>$variable</value> <value>function</value></syntax>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
150 <default/>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
151 <context>http</context>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
152
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
153 <para>
2128
59a3cc84f507 Renamed nginScript to njs
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2026
diff changeset
154 Sets an njs function for the specified variable.
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
155 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
156
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
157 </directive>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
158
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
159 </section>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
160
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
161
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
162 <section id="arguments" name="Request and Response Arguments">
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
163 <para>
2128
59a3cc84f507 Renamed nginScript to njs
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2026
diff changeset
164 Each HTTP njs handler receives two arguments, request and response.
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
165 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
166
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
167 <para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
168 The request object has the following properties:
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
169 <list type="tag">
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
170
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
171 <tag-name><literal>uri</literal></tag-name>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
172 <tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
173 current URI in a request, read-only
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
174 </tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
175
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
176 <tag-name><literal>method</literal></tag-name>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
177 <tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
178 request method, read-only
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
179 </tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
180
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
181 <tag-name><literal>httpVersion</literal></tag-name>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
182 <tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
183 HTTP version, read-only
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
184 </tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
185
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
186 <tag-name><literal>remoteAddress</literal></tag-name>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
187 <tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
188 client address, read-only
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
189 </tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
190
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
191 <tag-name><literal>headers{}</literal></tag-name>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
192 <tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
193 request headers object, read-only.
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
194 <para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
195 For example, the <literal>Header-Name</literal> header
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
196 can be accessed with the syntax <literal>headers['Header-Name']</literal>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
197 or <literal>headers.Header_name</literal>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
198 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
199 </tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
200
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
201 <tag-name><literal>args{}</literal></tag-name>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
202 <tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
203 request arguments object, read-only
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
204 </tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
205
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
206 <tag-name><literal>variables{}</literal></tag-name>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
207 <tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
208 nginx variables object, read-only
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
209 </tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
210
2149
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
211 <tag-name><literal>response</literal></tag-name>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
212 <tag-desc>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
213 the response object (0.2.0), read-only
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
214 </tag-desc>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
215 </list>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
216 </para>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
217
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
218 <para>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
219 The request object has the following methods:
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
220 <list type="tag">
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
221
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
222 <tag-name><literal>log(<value>string</value>)</literal></tag-name>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
223 <tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
224 writes a <literal>string</literal> to the error log
2135
6c7841469ec5 Specified logging level for the "log" argument in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2128
diff changeset
225 on the <literal>info</literal> level of logging
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
226 </tag-desc>
2149
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
227
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
228 <tag-name><literal>warn(<value>string</value>)</literal></tag-name>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
229 <tag-desc>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
230 writes a <literal>string</literal> to the error log
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
231 on the <literal>warning</literal> level of logging (0.2.0)
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
232 </tag-desc>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
233
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
234 <tag-name><literal>error(<value>string</value>)</literal></tag-name>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
235 <tag-desc>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
236 writes a <literal>string</literal> to the error log
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
237 on the <literal>error</literal> level of logging (0.2.0)
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
238 </tag-desc>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
239
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
240 <tag-name><literal>subrequest(<value>uri</value>[, <value>options</value>[,
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
241 <value>callback</value>]])</literal></tag-name>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
242 <tag-desc>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
243 creates a subrequest with the given <literal>uri</literal> and
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
244 <literal>options</literal>, and installs
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
245 an optional completion <literal>callback</literal> (0.2.0).
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
246
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
247 <para>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
248 If <literal>options</literal> is a string, then it
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
249 holds the subrequest arguments string.
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
250 Otherwise <literal>options</literal> is expected to be
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
251 an object with the following keys:
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
252 <list type="tag">
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
253 <tag-name><literal>args</literal></tag-name>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
254 <tag-desc>arguments string</tag-desc>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
255
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
256 <tag-name><literal>body</literal></tag-name>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
257 <tag-desc>request body</tag-desc>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
258
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
259 <tag-name><literal>method</literal></tag-name>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
260 <tag-desc>HTTP method</tag-desc>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
261 </list>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
262 </para>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
263
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
264 <para>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
265 The <literal>callback</literal> receives a response object
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
266 with the following properties:
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
267 <literal>uri</literal>, <literal>method</literal>,
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
268 <literal>status</literal>, <literal>contentType</literal>,
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
269 <literal>contentLength</literal>, <literal>headers</literal>,
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
270 <literal>args</literal>.
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
271 These properties have the same meaning as the request object properties.
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
272 Additionally, a reply object has the <literal>body</literal> property
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
273 holding the subrequest response body
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
274 and the <literal>parent</literal> property
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
275 referencing the parent request object.
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
276 </para>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
277 </tag-desc>
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
278 </list>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
279 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
280
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
281 <para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
282 The response object has the following properties:
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
283 <list type="tag">
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
284
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
285 <tag-name><literal>status</literal></tag-name>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
286 <tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
287 response status, writable
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
288 </tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
289
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
290 <tag-name><literal>headers{}</literal></tag-name>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
291 <tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
292 response headers object
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
293 </tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
294
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
295 <tag-name><literal>contentType</literal></tag-name>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
296 <tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
297 the response <header>Content-Type</header> header field value, writable
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
298 </tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
299
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
300 <tag-name><literal>contentLength</literal></tag-name>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
301 <tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
302 the response <header>Content-Length</header> header field value, writable
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
303 </tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
304 </list>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
305 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
306
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
307 <para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
308 The response object has the following methods:
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
309 <list type="tag">
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
310
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
311 <tag-name><literal>sendHeader()</literal></tag-name>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
312 <tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
313 sends the HTTP header to the client
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
314 </tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
315
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
316 <tag-name><literal>send(<value>string</value>)</literal></tag-name>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
317 <tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
318 sends a part of the response body to the client
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
319 </tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
320
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
321 <tag-name><literal>finish()</literal></tag-name>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
322 <tag-desc>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
323 finishes sending a response to the client
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
324 </tag-desc>
2149
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
325
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
326 <tag-name><literal>return(status[, string])</literal></tag-name>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
327 <tag-desc>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
328 sends
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
329 the entire response with the specified <literal>status</literal> to the client
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
330 (0.2.0)
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
331 <para>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
332 It is possible to specify either a redirect URL
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
333 (for codes 301, 302, 303, 307, and 308)
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
334 or the response body text (for other codes) as the second argument.
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
335 </para>
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
336 </tag-desc>
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
337 </list>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
338 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
339
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
340 </section>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
341
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
342 </module>