Mercurial > hg > nginx-site
annotate xml/en/docs/njs/reference.xml @ 2908:b2e5a376622d
Updated with Netcraft November 2022 Web Server Survey stats.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Wed, 16 Nov 2022 15:52:18 +0000 |
parents | 4aaab86a9c26 |
children | 5f1d472f6a97 |
rev | line source |
---|---|
2175
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
1 <?xml version="1.0"?> |
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
2 |
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
3 <!-- |
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
4 Copyright (C) Nginx, Inc. |
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
5 --> |
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
6 |
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> |
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
8 |
2246
32ba43abf9cd
Renamed njs API, njs Changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2245
diff
changeset
|
9 <article name="Reference" |
32ba43abf9cd
Renamed njs API, njs Changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2245
diff
changeset
|
10 link="/en/docs/njs/reference.html" |
2175
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
11 lang="en" |
2904
4aaab86a9c26
Added the njs.memoryStats property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2902
diff
changeset
|
12 rev="92"> |
2175
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
13 |
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
14 <section id="summary"> |
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
15 |
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
16 <para> |
2244
467aef18bf12
Renamed the "About njs" page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2237
diff
changeset
|
17 <link doc="index.xml">njs</link> provides objects, methods and properties |
2175
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
18 for extending nginx functionality. |
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
19 </para> |
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
20 |
2569
2edc64c05b0e
Removed ECMAScript methods from njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2564
diff
changeset
|
21 <para> |
2edc64c05b0e
Removed ECMAScript methods from njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2564
diff
changeset
|
22 This reference contains only njs specific properties, methods and modules |
2edc64c05b0e
Removed ECMAScript methods from njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2564
diff
changeset
|
23 not compliant with ECMAScript. |
2edc64c05b0e
Removed ECMAScript methods from njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2564
diff
changeset
|
24 Definitions of njs properties and methods compliant with ECMAScript |
2edc64c05b0e
Removed ECMAScript methods from njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2564
diff
changeset
|
25 can be found in |
2edc64c05b0e
Removed ECMAScript methods from njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2564
diff
changeset
|
26 <link url="http://www.ecma-international.org/ecma-262/">ECMAScript |
2edc64c05b0e
Removed ECMAScript methods from njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2564
diff
changeset
|
27 specification</link>. |
2edc64c05b0e
Removed ECMAScript methods from njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2564
diff
changeset
|
28 List of all njs properties and methods can be found in |
2edc64c05b0e
Removed ECMAScript methods from njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2564
diff
changeset
|
29 <link doc="compatibility.xml">Compatibility</link>. |
2edc64c05b0e
Removed ECMAScript methods from njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2564
diff
changeset
|
30 </para> |
2edc64c05b0e
Removed ECMAScript methods from njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2564
diff
changeset
|
31 |
2175
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
32 </section> |
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
33 |
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
34 |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
35 <section id="http_stream" name="nginx objects"> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
36 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
37 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
38 <section id="http" name="HTTP Request"> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
39 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
40 <para> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
41 The HTTP request object is available only in the |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
42 <link doc="../http/ngx_http_js_module.xml">ngx_http_js_module</link> module. |
2570
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
43 All string properties of the object are |
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
44 <link id="string">byte strings</link>. |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
45 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
46 <list type="tag"> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
47 |
2353 | 48 <tag-name id="r_args"><literal>r.args{}</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
49 <tag-desc> |
2872
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
50 request arguments object, read-only. |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
51 <para> |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
52 The query string is returned as an object. |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
53 Since <link doc="changes.xml" id="njs0.7.6">0.7.6</link>, |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
54 duplicate keys are returned as an array, |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
55 keys are case-sensitive, both keys and values are percent-decoded. |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
56 </para> |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
57 |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
58 <para> |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
59 For example, the query string |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
60 <example> |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
61 'a=1&b=%32&A=3&b=4&B=two%20words' |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
62 </example> |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
63 is converted to <literal>r.args</literal> as: |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
64 <example> |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
65 {a: "1", b: ["2", "4"], A: "3", B: "two words"} |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
66 </example> |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
67 More advanced parsing scenarios can be achieved with the |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
68 <link id="querystring">Query String</link> module |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
69 and with the |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
70 <link doc="../http/ngx_http_core_module.xml" id="var_args"><literal>$args</literal></link> |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
71 variable, for example: |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
72 |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
73 <example> |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
74 import qs from 'querystring'; |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
75 |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
76 function args(r) { |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
77 return qs.parse(r.variables.args); |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
78 } |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
79 </example> |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
80 The argument object |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
81 is evaluated at the first access to <literal>r.args</literal>. |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
82 If only a single argument is needed, for example <literal>foo</literal>, |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
83 <link doc="../varindex.xml">nginx variables</link> can be used: |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
84 <example> |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
85 r.variables.arg_foo |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
86 </example> |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
87 Here, <link id="r_variables">nginx variables object</link> |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
88 returns the first value for a given key, |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
89 case-insensitive, without percent-decoding. |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
90 </para> |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
91 |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
92 <para> |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
93 To convert <literal>r.args</literal> back to a string, |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
94 the Query String |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
95 <link id="querystring_stringify"><literal>stringify</literal></link> |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
96 method can be used. |
1e1a15c84515
Extended description of r.args in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2848
diff
changeset
|
97 </para> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
98 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
99 |
2663
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
100 <tag-name id="r_done"><literal>r.done()</literal></tag-name> |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
101 <tag-desc> |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
102 after calling this function, |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
103 next data chunks will be passed to client without calling |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
104 <link doc="../http/ngx_http_js_module.xml" id="js_body_filter"/> |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
105 (<link doc="changes.xml" id="njs0.5.2">0.5.2</link>). |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
106 May be called only from the |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
107 <link doc="../http/ngx_http_js_module.xml" id="js_body_filter"/> function |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
108 </tag-desc> |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
109 |
2570
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
110 <tag-name id="r_error"><literal>r.error(<value>string</value>)</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
111 <tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
112 writes a <literal>string</literal> to the error log |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
113 on the <literal>error</literal> level of logging |
2877
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
114 <para> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
115 <note> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
116 As nginx has a |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
117 <link doc="../dev/development_guide.xml" id="logging">hardcoded</link> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
118 maximum line length limit, |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
119 only first 2048 bytes of the string can be logged. |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
120 </note> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
121 </para> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
122 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
123 |
2570
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
124 <tag-name id="r_finish"><literal>r.finish()</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
125 <tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
126 finishes sending a response to the client |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
127 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
128 |
2353 | 129 <tag-name id="r_headers_in"><literal>r.headersIn{}</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
130 <tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
131 incoming headers object, read-only. |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
132 <para> |
2543
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
133 The <literal>Foo</literal> request header |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
134 can be accessed with the syntax: |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
135 <literal>headersIn.foo</literal> or <literal>headersIn['Foo']</literal>. |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
136 </para> |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
137 |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
138 <para> |
2735
ff357b676c2e
Removed trailing spaces.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2716
diff
changeset
|
139 The |
2543
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
140 <header>Authorization</header>, |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
141 <header>Content-Length</header>, |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
142 <header>Content-Range</header>, |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
143 <header>Content-Type</header>, |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
144 <header>ETag</header>, |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
145 <header>Expect</header>, |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
146 <header>From</header>, |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
147 <header>Host</header>, |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
148 <header>If-Match</header>, |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
149 <header>If-Modified-Since</header>, |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
150 <header>If-None-Match</header>, |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
151 <header>If-Range</header>, |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
152 <header>If-Unmodified-Since</header>, |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
153 <header>Max-Forwards</header>, |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
154 <header>Proxy-Authorization</header>, |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
155 <header>Referer</header>, |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
156 <header>Transfer-Encoding</header>, and |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
157 <header>User-Agent</header> |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
158 request headers can have only one field value |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
159 (<link doc="changes.xml" id="njs0.4.1">0.4.1</link>). |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
160 Duplicate field values in <header>Cookie</header> headers |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
161 are separated by semicolon (<literal>;</literal>). |
f39c4724c0f8
Described multi-value headers in r.headersIn.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2537
diff
changeset
|
162 Duplicate field values in all other request headers are separated by commas. |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
163 </para> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
164 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
165 |
2331 | 166 <tag-name id="r_headers_out"><literal>r.headersOut{}</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
167 <tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
168 outgoing headers object, writable. |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
169 <para> |
2532
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
170 The <header>Foo</header> response header |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
171 can be accessed with the syntax: |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
172 <literal>headersOut.foo</literal> or <literal>headersOut['Foo']</literal>. |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
173 </para> |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
174 |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
175 <para> |
2894
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
176 Outgoing headers should be set before a response header is sent to a client, |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
177 otherwise header update will be ignored. |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
178 This means that <literal>r.headersOut{}</literal> is effectively writable in: |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
179 |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
180 <list type="bullet"> |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
181 |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
182 <listitem> |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
183 the <link doc="../http/ngx_http_js_module.xml" id="js_content"/> handler before |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
184 <link id="r_send_header"><literal>r.sendHeader()</literal></link> or |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
185 <link id="r_return"><literal>r.return()</literal></link> are called |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
186 </listitem> |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
187 |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
188 <listitem> |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
189 the <link doc="../http/ngx_http_js_module.xml" id="js_header_filter"/> handler |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
190 </listitem> |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
191 |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
192 </list> |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
193 </para> |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
194 |
438a9cfa4fae
Added info about setting r.headersOut in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2888
diff
changeset
|
195 <para> |
2532
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
196 Field values of multi-value response headers |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
197 (<link doc="changes.xml" id="njs0.4.0">0.4.0</link>) |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
198 can be set with the syntax: |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
199 <example> |
2544
33347df1da9c
Relocated sentence in r.headers.Out, added dot, corrected quotes.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2543
diff
changeset
|
200 r.headersOut['Foo'] = ['a', 'b'] |
2532
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
201 </example> |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
202 where the output will be: |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
203 <example> |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
204 Foo: a |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
205 Foo: b |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
206 </example> |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
207 All previous field values of the <header>Foo</header> response header |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
208 will be deleted. |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
209 </para> |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
210 |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
211 <para> |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
212 For standard response headers |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
213 that accept only a single field value such as |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
214 <header>Content-Type</header>, |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
215 only the last element of the array will take effect. |
2544
33347df1da9c
Relocated sentence in r.headers.Out, added dot, corrected quotes.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2543
diff
changeset
|
216 Field values of the <header>Set-Cookie</header> response header |
33347df1da9c
Relocated sentence in r.headers.Out, added dot, corrected quotes.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2543
diff
changeset
|
217 are always returned as an array. |
2532
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
218 Duplicate field values in |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
219 <header>Age</header>, |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
220 <header>Content-Encoding</header>, |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
221 <header>Content-Length</header>, |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
222 <header>Content-Type</header>, |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
223 <header>ETag</header>, |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
224 <header>Expires</header>, |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
225 <header>Last-Modified</header>, |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
226 <header>Location</header>, |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
227 <header>Retry-After</header> |
423d813dc8bb
Documented support for multi-value headers in r.headersOut.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2525
diff
changeset
|
228 response headers are ignored. |
2537
d6bbfd20c82f
Rephrased a sentence in r.headersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2532
diff
changeset
|
229 Duplicate field values in all other response headers |
d6bbfd20c82f
Rephrased a sentence in r.headersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2532
diff
changeset
|
230 are separated by commas. |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
231 </para> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
232 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
233 |
2570
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
234 <tag-name id="r_http_version"><literal>r.httpVersion</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
235 <tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
236 HTTP version, read-only |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
237 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
238 |
2888
88956e57f930
Documented r.internal in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2887
diff
changeset
|
239 <tag-name id="r_internal"><literal>r.internal</literal></tag-name> |
88956e57f930
Documented r.internal in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2887
diff
changeset
|
240 <tag-desc> |
88956e57f930
Documented r.internal in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2887
diff
changeset
|
241 boolean value, true for |
88956e57f930
Documented r.internal in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2887
diff
changeset
|
242 <link doc="../http/ngx_http_core_module.xml" id="internal">internal</link> |
88956e57f930
Documented r.internal in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2887
diff
changeset
|
243 locations |
88956e57f930
Documented r.internal in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2887
diff
changeset
|
244 </tag-desc> |
88956e57f930
Documented r.internal in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2887
diff
changeset
|
245 |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
246 <tag-name id="r_internal_redirect"><literal>r.internalRedirect(<value>uri</value>)</literal></tag-name> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
247 <tag-desc> |
2685
5282d6d3d849
Improved descripion of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2679
diff
changeset
|
248 performs an |
5282d6d3d849
Improved descripion of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2679
diff
changeset
|
249 <link doc="../dev/development_guide.xml" id="http_request_redirection">internal |
5282d6d3d849
Improved descripion of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2679
diff
changeset
|
250 redirect</link> |
5282d6d3d849
Improved descripion of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2679
diff
changeset
|
251 to the specified <literal>uri</literal>. |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
252 If the uri starts with the “<literal>@</literal>” prefix, |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
253 it is considered a named location. |
2685
5282d6d3d849
Improved descripion of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2679
diff
changeset
|
254 Redirected requests become internal and can access the |
5282d6d3d849
Improved descripion of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2679
diff
changeset
|
255 <link doc="../http/ngx_http_core_module.xml" id="internal">internal</link> |
5282d6d3d849
Improved descripion of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2679
diff
changeset
|
256 locations. |
2525
6ce28e0beec0
Updated description of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2509
diff
changeset
|
257 The actual redirect happens after the handler execution is completed. |
2685
5282d6d3d849
Improved descripion of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2679
diff
changeset
|
258 <para> |
5282d6d3d849
Improved descripion of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2679
diff
changeset
|
259 <note> |
5282d6d3d849
Improved descripion of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2679
diff
changeset
|
260 After redirect, |
5282d6d3d849
Improved descripion of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2679
diff
changeset
|
261 a new njs VM is started in the target location, |
5282d6d3d849
Improved descripion of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2679
diff
changeset
|
262 the VM in the original location is stopped. |
5282d6d3d849
Improved descripion of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2679
diff
changeset
|
263 Values of nginx variables are kept |
5282d6d3d849
Improved descripion of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2679
diff
changeset
|
264 and can be used to pass information to the target location. |
2716
f82f16e327f2
Added info about js_var to r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2693
diff
changeset
|
265 Since <link doc="changes.xml" id="njs0.5.3">0.5.3</link>, |
f82f16e327f2
Added info about js_var to r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2693
diff
changeset
|
266 the variable declared with the <literal>js_var</literal> directive for |
f82f16e327f2
Added info about js_var to r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2693
diff
changeset
|
267 <link doc="../http/ngx_http_js_module.xml" id="js_var">http</link> or |
f82f16e327f2
Added info about js_var to r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2693
diff
changeset
|
268 <link doc="../stream/ngx_stream_js_module.xml" id="js_var">stream</link> |
f82f16e327f2
Added info about js_var to r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2693
diff
changeset
|
269 can be used. |
2685
5282d6d3d849
Improved descripion of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2679
diff
changeset
|
270 </note> |
5282d6d3d849
Improved descripion of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2679
diff
changeset
|
271 </para> |
5282d6d3d849
Improved descripion of r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2679
diff
changeset
|
272 |
2848
c8d57f14c51b
Documented escaped URIs for r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2847
diff
changeset
|
273 <para> |
c8d57f14c51b
Documented escaped URIs for r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2847
diff
changeset
|
274 <note> |
c8d57f14c51b
Documented escaped URIs for r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2847
diff
changeset
|
275 Since <link doc="changes.xml" id="njs0.7.4">0.7.4</link>, |
c8d57f14c51b
Documented escaped URIs for r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2847
diff
changeset
|
276 the method accepts escaped URIs. |
c8d57f14c51b
Documented escaped URIs for r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2847
diff
changeset
|
277 </note> |
c8d57f14c51b
Documented escaped URIs for r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2847
diff
changeset
|
278 </para> |
c8d57f14c51b
Documented escaped URIs for r.internalRedirect in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2847
diff
changeset
|
279 |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
280 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
281 |
2570
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
282 <tag-name id="r_log"><literal>r.log(<value>string</value>)</literal></tag-name> |
2545
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
283 <tag-desc> |
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
284 writes a <literal>string</literal> to the error log |
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
285 on the <literal>info</literal> level of logging |
2877
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
286 <para> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
287 <note> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
288 As nginx has a |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
289 <link doc="../dev/development_guide.xml" id="logging">hardcoded</link> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
290 maximum line length limit, |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
291 only first 2048 bytes of the string can be logged. |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
292 </note> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
293 </para> |
2545
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
294 </tag-desc> |
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
295 |
2570
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
296 <tag-name id="r_method"><literal>r.method</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
297 <tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
298 HTTP method, read-only |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
299 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
300 |
2497
805c4b84cc61
Added missing feature and links to njs-0.3.8 Changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2496
diff
changeset
|
301 <tag-name id="r_parent"><literal>r.parent</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
302 <tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
303 references the parent request object |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
304 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
305 |
2570
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
306 <tag-name id="r_remote_address"><literal>r.remoteAddress</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
307 <tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
308 client address, read-only |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
309 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
310 |
2628 | 311 <tag-name id="r_request_body"><literal>r.requestBody</literal></tag-name> |
312 <tag-desc> | |
313 the property is deprecated since | |
314 <link doc="changes.xml" id="njs0.5.0">0.5.0</link>, | |
315 the <link id="r_request_buffer"><literal>r.requestBuffer</literal></link> or | |
316 <link id="r_request_text"><literal>r.requestText</literal></link> property | |
317 should be used instead. | |
318 </tag-desc> | |
319 | |
320 <tag-name id="r_request_buffer"><literal>r.requestBuffer</literal></tag-name> | |
321 <tag-desc> | |
322 client request body if it has not been written to a temporary file | |
323 (since <link doc="changes.xml" id="njs0.5.0">0.5.0</link>). | |
324 To ensure that the client request body is in memory, | |
325 its size should be limited by | |
326 <link doc="../http/ngx_http_core_module.xml" id="client_max_body_size"/>, | |
327 and a sufficient buffer size should be set using | |
328 <link doc="../http/ngx_http_core_module.xml" id="client_body_buffer_size"/>. | |
329 The property is available only in the | |
330 <link doc="../http/ngx_http_js_module.xml" id="js_content"/> directive. | |
331 </tag-desc> | |
332 | |
333 <tag-name id="r_request_text"><literal>r.requestText</literal></tag-name> | |
334 <tag-desc> | |
335 the same as <link id="r_request_buffer"><literal>r.requestBuffer</literal></link>, | |
336 but returns a <literal>string</literal>. | |
337 Note that | |
2688
dd2bbd104146
Unified spelling of UTF-8 in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2687
diff
changeset
|
338 it may convert bytes invalid in UTF-8 encoding into the replacement character. |
2628 | 339 </tag-desc> |
340 | |
2546
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
341 <tag-name id="r_raw_headers_in"><literal>r.rawHeadersIn{}</literal></tag-name> |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
342 <tag-desc> |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
343 returns an array of key-value pairs |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
344 exactly as they were received from the client |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
345 (<link doc="changes.xml" id="njs0.4.1">0.4.1</link>). |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
346 <para> |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
347 For example, with the following request headers: |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
348 <example> |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
349 Host: localhost |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
350 Foo: bar |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
351 foo: bar2 |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
352 </example> |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
353 the output of <literal>r.rawHeadersIn</literal> will be: |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
354 <example> |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
355 [ |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
356 ['Host', 'localhost'], |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
357 ['Foo', 'bar'], |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
358 ['foo', 'bar2'] |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
359 ] |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
360 </example> |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
361 All <literal>foo</literal> headers |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
362 can be collected with the syntax: |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
363 <example> |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
364 r.rawHeadersIn.filter(v=>v[0].toLowerCase() == 'foo').map(v=>v[1]) |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
365 </example> |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
366 the output will be: |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
367 <example> |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
368 ['bar', 'bar2'] |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
369 </example> |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
370 Header field names are not converted to lower case, |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
371 duplicate field values are not merged. |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
372 </para> |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
373 </tag-desc> |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
374 |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
375 <tag-name id="r_raw_headers_out"><literal>r.rawHeadersOut{}</literal></tag-name> |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
376 <tag-desc> |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
377 returns an array of key-value pairs of response headers |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
378 (<link doc="changes.xml" id="njs0.4.1">0.4.1</link>). |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
379 Header field names are not converted to lower case, |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
380 duplicate field values are not merged. |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
381 </tag-desc> |
6093e9f3615e
Documented rawHeadersIn and rawHeadersOut in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2545
diff
changeset
|
382 |
2628 | 383 <tag-name id="r_response_body"><literal>r.responseBody</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
384 <tag-desc> |
2628 | 385 the property is deprecated since |
386 <link doc="changes.xml" id="njs0.5.0">0.5.0</link>, | |
387 the <link id="r_response_buffer"><literal>r.responseBuffer</literal></link> | |
388 or | |
389 the <link id="r_response_text"><literal>r.responseText</literal></link> | |
390 property | |
391 should be used instead. | |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
392 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
393 |
2628 | 394 <tag-name id="r_response_buffer"><literal>r.responseBuffer</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
395 <tag-desc> |
2628 | 396 holds the <link id="r_subrequest">subrequest</link> response body, |
397 read-only | |
398 (since <link doc="changes.xml" id="njs0.5.0">0.5.0</link>). | |
399 The size of <literal>r.responseBuffer</literal> is limited by the | |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
400 <link doc="../http/ngx_http_core_module.xml" id="subrequest_output_buffer_size"/> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
401 directive. |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
402 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
403 |
2628 | 404 <tag-name id="r_response_text"><literal>r.responseText</literal></tag-name> |
405 <tag-desc> | |
406 the same as <link id="r_response_buffer"><literal>r.responseBuffer</literal></link> | |
407 but returns a string | |
408 (since <link doc="changes.xml" id="njs0.5.0">0.5.0</link>). | |
409 Note that | |
2688
dd2bbd104146
Unified spelling of UTF-8 in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2687
diff
changeset
|
410 it may convert bytes invalid in UTF-8 encoding into the replacement character. |
2628 | 411 </tag-desc> |
412 | |
413 <tag-name id="r_return"><literal>r.return(status[, | |
414 string | Buffer])</literal></tag-name> | |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
415 <tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
416 sends the entire response |
2628 | 417 with the specified <literal>status</literal> to the client. |
418 The response can be a string or Buffer | |
419 (<link doc="changes.xml" id="njs0.5.0">0.5.0</link>). | |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
420 <para> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
421 It is possible to specify either a redirect URL |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
422 (for codes 301, 302, 303, 307, and 308) |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
423 or the response body text (for other codes) as the second argument |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
424 </para> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
425 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
426 |
2628 | 427 <tag-name id="r_send"><literal>r.send(string |
428 | Buffer)</literal></tag-name> | |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
429 <tag-desc> |
2628 | 430 sends a part of the response body to the client. |
431 The data sent can be a string or Buffer | |
432 (<link doc="changes.xml" id="njs0.5.0">0.5.0</link>) | |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
433 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
434 |
2663
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
435 <tag-name id="r_sendbuffer"><literal>r.sendBuffer(<value>data</value>[, |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
436 <value>options</value>])</literal></tag-name> |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
437 <tag-desc> |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
438 adds data to the chain of data chunks to be forwarded to the next body filter |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
439 (<link doc="changes.xml" id="njs0.5.2">0.5.2</link>). |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
440 The actual forwarding happens later, |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
441 when the all the data chunks of the current chain are processed. |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
442 <para> |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
443 The data can be a string or Buffer. |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
444 The <literal>options</literal> is an object used |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
445 to override nginx buffer flags derived from an incoming data chunk buffer. |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
446 The flags can be overridden with the following flags: |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
447 <list type="tag"> |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
448 |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
449 <tag-name><literal>last</literal></tag-name> |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
450 <tag-desc> |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
451 boolean, |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
452 true if the buffer is the last buffer |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
453 </tag-desc> |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
454 |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
455 <tag-name><literal>flush</literal></tag-name> |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
456 <tag-desc> |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
457 boolean, |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
458 true if the buffer should have the <literal>flush</literal> flag |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
459 </tag-desc> |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
460 </list> |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
461 </para> |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
462 The method may be called only from the |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
463 <link doc="../http/ngx_http_js_module.xml" id="js_body_filter"/> function. |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
464 </tag-desc> |
a33d8f0f48b2
Documented r.done and r.sendBuffer in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2653
diff
changeset
|
465 |
2571
3e47eecce384
Added id to r.sendHeader in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2570
diff
changeset
|
466 <tag-name id="r_send_header"><literal>r.sendHeader()</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
467 <tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
468 sends the HTTP headers to the client |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
469 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
470 |
2800
3a146e49f9d4
Corrected syntax of r.setReturnValue and s.setReturnValue.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2792
diff
changeset
|
471 <tag-name id="r_set_return_value"><literal>r.setReturnValue(<value>value</value>)</literal></tag-name> |
2777
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
472 <tag-desc> |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
473 sets the return value of the |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
474 <link doc="../http/ngx_http_js_module.xml" id="js_set"/> handler |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
475 (<link doc="changes.xml" id="njs0.7.0">0.7.0</link>). |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
476 Unlike an ordinary return statement, |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
477 this method should be used when the handler is JS async function. |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
478 For example: |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
479 <example> |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
480 async function js_set(r) { |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
481 const digest = await crypto.subtle.digest('SHA-256', r.headersIn.host); |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
482 r.setReturnValue(digest); |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
483 } |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
484 </example> |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
485 </tag-desc> |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
486 |
2570
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
487 <tag-name id="r_status"><literal>r.status</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
488 <tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
489 status, writable |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
490 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
491 |
2570
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
492 <tag-name id="r_subrequest"><literal>r.subrequest(<value>uri</value>[, |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
493 <value>options</value>[, <value>callback</value>]])</literal></tag-name> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
494 <tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
495 creates a subrequest with the given <literal>uri</literal> and |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
496 <literal>options</literal>, and installs |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
497 an optional completion <literal>callback</literal>. |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
498 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
499 <para> |
2340
537130c40c1f
Updated r.subrequest desctiption in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2338
diff
changeset
|
500 A |
537130c40c1f
Updated r.subrequest desctiption in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2338
diff
changeset
|
501 <link doc="../dev/development_guide.xml.xml" id="http_subrequests">subrequest</link> |
537130c40c1f
Updated r.subrequest desctiption in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2338
diff
changeset
|
502 shares its input headers with the client request. |
537130c40c1f
Updated r.subrequest desctiption in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2338
diff
changeset
|
503 To send headers different from original headers to a proxied server, the |
537130c40c1f
Updated r.subrequest desctiption in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2338
diff
changeset
|
504 <link doc="../http/ngx_http_proxy_module.xml" id="proxy_set_header"/> |
537130c40c1f
Updated r.subrequest desctiption in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2338
diff
changeset
|
505 directive can be used. |
537130c40c1f
Updated r.subrequest desctiption in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2338
diff
changeset
|
506 To send a completely new set of headers to a proxied server, the |
537130c40c1f
Updated r.subrequest desctiption in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2338
diff
changeset
|
507 <link doc="../http/ngx_http_proxy_module.xml" id="proxy_pass_request_headers"/> |
537130c40c1f
Updated r.subrequest desctiption in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2338
diff
changeset
|
508 directive can be used. |
537130c40c1f
Updated r.subrequest desctiption in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2338
diff
changeset
|
509 </para> |
537130c40c1f
Updated r.subrequest desctiption in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2338
diff
changeset
|
510 |
537130c40c1f
Updated r.subrequest desctiption in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2338
diff
changeset
|
511 <para> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
512 If <literal>options</literal> is a string, then it |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
513 holds the subrequest arguments string. |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
514 Otherwise, <literal>options</literal> is expected to be |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
515 an object with the following keys: |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
516 <list type="tag"> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
517 <tag-name><literal>args</literal></tag-name> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
518 <tag-desc> |
2344
ea8ccaac18b4
Added default values for r.subrequest options in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2340
diff
changeset
|
519 arguments string, by default an empty string is used |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
520 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
521 <tag-name><literal>body</literal></tag-name> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
522 <tag-desc> |
2344
ea8ccaac18b4
Added default values for r.subrequest options in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2340
diff
changeset
|
523 request body, |
ea8ccaac18b4
Added default values for r.subrequest options in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2340
diff
changeset
|
524 by default the request body of the parent request object is used |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
525 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
526 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
527 <tag-name><literal>method</literal></tag-name> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
528 <tag-desc> |
2344
ea8ccaac18b4
Added default values for r.subrequest options in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2340
diff
changeset
|
529 HTTP method, by default the <literal>GET</literal> method is used |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
530 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
531 |
2507 | 532 <tag-name><literal>detached</literal></tag-name> |
533 <tag-desc> | |
534 boolean flag (<link doc="changes.xml" id="njs0.3.9">0.3.9</link>), | |
535 if <literal>true</literal>, the created subrequest is a detached subrequest. | |
536 Responses to detached subrequests are ignored. | |
537 Unlike ordinary subrequests, a detached subrequest | |
538 can be created inside a variable handler. | |
2579
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
539 The <literal>detached</literal> flag and callback argument |
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
540 are mutually exclusive. |
2507 | 541 </tag-desc> |
542 | |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
543 </list> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
544 </para> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
545 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
546 <para> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
547 The completion <literal>callback</literal> receives |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
548 a subrequest response object with methods and properties |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
549 identical to the parent request object. |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
550 </para> |
2484
2aa02672d54f
Added a note to r.subrequest in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2446
diff
changeset
|
551 |
2aa02672d54f
Added a note to r.subrequest in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2446
diff
changeset
|
552 <para> |
2aa02672d54f
Added a note to r.subrequest in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2446
diff
changeset
|
553 Since <link doc="changes.xml" id="njs0.3.8">0.3.8</link>, |
2aa02672d54f
Added a note to r.subrequest in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2446
diff
changeset
|
554 if a <literal>callback</literal> is not provided, |
2aa02672d54f
Added a note to r.subrequest in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2446
diff
changeset
|
555 the <literal>Promise</literal> object |
2aa02672d54f
Added a note to r.subrequest in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2446
diff
changeset
|
556 that resolves to the subrequest response object is returned. |
2aa02672d54f
Added a note to r.subrequest in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2446
diff
changeset
|
557 </para> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
558 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
559 |
2545
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
560 <tag-name id="r_uri"><literal>r.uri</literal></tag-name> |
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
561 <tag-desc> |
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
562 current <link doc="../http/ngx_http_core_module.xml" id="var_uri">URI</link> |
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
563 in request, |
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
564 <link doc="../http/ngx_http_core_module.xml" id="location">normalized</link>, |
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
565 read-only |
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
566 </tag-desc> |
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
567 |
2628 | 568 <tag-name id="r_raw_variables"><literal>r.rawVariables{}</literal></tag-name> |
569 <tag-desc> | |
570 nginx <link id="r_variables">variables</link> as Buffers, | |
571 writable | |
572 (since <link doc="changes.xml" id="njs0.5.0">0.5.0</link>) | |
573 </tag-desc> | |
574 | |
2545
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
575 <tag-name id="r_variables"><literal>r.variables{}</literal></tag-name> |
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
576 <tag-desc> |
2579
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
577 nginx variables object, writable |
2689
7e271437f12e
Updated writable variables info in r.variables and s.variables.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2688
diff
changeset
|
578 (since <link doc="changes.xml" id="njs0.2.8">0.2.8</link>). |
2693
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
579 |
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
580 <para> |
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
581 A variable is writable if: |
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
582 <list type="bullet"> |
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
583 |
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
584 <listitem> |
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
585 it was created using the <literal>js_var</literal> directive for |
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
586 <link doc="../http/ngx_http_js_module.xml" id="js_var">http</link> or |
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
587 <link doc="../stream/ngx_stream_js_module.xml" id="js_var">stream</link> |
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
588 (since <link doc="changes.xml" id="njs0.5.3">0.5.3</link>) |
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
589 </listitem> |
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
590 |
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
591 <listitem> |
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
592 it is referenced in nginx configuration file |
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
593 </listitem> |
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
594 |
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
595 </list> |
2689
7e271437f12e
Updated writable variables info in r.variables and s.variables.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2688
diff
changeset
|
596 Even so, some embedded variables still cannot be assigned a value (for example, |
7e271437f12e
Updated writable variables info in r.variables and s.variables.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2688
diff
changeset
|
597 <link doc="../http/ngx_http_core_module.xml" id="var_http_"><literal>$http_</literal></link>). |
2693
3cbd6e440581
Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2689
diff
changeset
|
598 </para> |
2545
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
599 </tag-desc> |
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
600 |
2570
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
601 <tag-name id="r_warn"><literal>r.warn(<value>string</value>)</literal></tag-name> |
2545
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
602 <tag-desc> |
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
603 writes a <literal>string</literal> to the error log |
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
604 on the <literal>warning</literal> level of logging |
2877
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
605 <para> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
606 <note> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
607 As nginx has a |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
608 <link doc="../dev/development_guide.xml" id="logging">hardcoded</link> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
609 maximum line length limit, |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
610 only first 2048 bytes of the string can be logged. |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
611 </note> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
612 </para> |
2545
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
613 </tag-desc> |
dca5a7053a6c
Sorted alphabetically njs http methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2544
diff
changeset
|
614 |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
615 </list> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
616 </para> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
617 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
618 </section> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
619 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
620 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
621 <section id="stream" name="Stream Session"> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
622 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
623 <para> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
624 The stream session object is available only in the |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
625 <link doc="../stream/ngx_stream_js_module.xml">ngx_stream_js_module</link> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
626 module. |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
627 All string properties of the object are <link id="string">byte strings</link>. |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
628 </para> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
629 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
630 <para> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
631 <list type="tag"> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
632 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
633 <tag-name id="s_allow"><literal>s.allow()</literal></tag-name> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
634 <tag-desc> |
2670
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
635 an alias to |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
636 <link id="s_done"><literal>s.done(0)</literal></link> |
2337
867fe207f13e
Updated links to changes.xml in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
637 (<link doc="changes.xml" id="njs0.2.4">0.2.4</link>) |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
638 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
639 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
640 <tag-name id="s_decline"><literal>s.decline()</literal></tag-name> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
641 <tag-desc> |
2670
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
642 an alias to |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
643 <link id="s_done"><literal>s.done(-5)</literal></link> |
2337
867fe207f13e
Updated links to changes.xml in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
644 (<link doc="changes.xml" id="njs0.2.4">0.2.4</link>) |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
645 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
646 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
647 <tag-name id="s_deny"><literal>s.deny()</literal></tag-name> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
648 <tag-desc> |
2670
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
649 an alias to |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
650 <link id="s_done"><literal>s.done(403)</literal></link> |
2337
867fe207f13e
Updated links to changes.xml in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
651 (<link doc="changes.xml" id="njs0.2.4">0.2.4</link>) |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
652 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
653 |
2670
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
654 <tag-name id="s_done"><literal>s.done([<value>code</value>]</literal>)</tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
655 <tag-desc> |
2670
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
656 sets an exit <literal>code</literal> for the current |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
657 <link doc="../stream/stream_processing.xml">phase</link> handler |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
658 to a code value, by default <literal>0</literal>. |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
659 The actual finalization happens when the js handler is completed |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
660 and all pending events, for example, from |
2679
8f3e9ff2785f
Corrected syntax of njs.on() and ngx.fetch() in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2670
diff
changeset
|
661 <link id="ngx_fetch"><literal>ngx.fetch()</literal></link> or |
2670
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
662 <link id="settimeout"><literal>setTimeout()</literal></link>, |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
663 are processed |
2337
867fe207f13e
Updated links to changes.xml in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
664 (<link doc="changes.xml" id="njs0.2.4">0.2.4</link>). |
2670
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
665 <para> |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
666 Possible code values: |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
667 <list type="bullet"> |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
668 |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
669 <listitem> |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
670 <literal>0</literal>— |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
671 successful finalization, passing control to the next phase |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
672 </listitem> |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
673 |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
674 <listitem> |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
675 <literal>-5</literal>— |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
676 undecided, passing control to the next handler of the current phase (if any) |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
677 </listitem> |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
678 |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
679 <listitem> |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
680 <literal>403</literal>— |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
681 access is forbidden |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
682 </listitem> |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
683 |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
684 </list> |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
685 </para> |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
686 May be called only from a phase handler function: |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
687 <link doc="../stream/ngx_stream_js_module.xml" id="js_access"><literal>js_access</literal></link> |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
688 or |
e53592a1d979
Improved descriptions of s.done, s.allow, s.decline, s.deny.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2668
diff
changeset
|
689 <link doc="../stream/ngx_stream_js_module.xml" id="js_preread"><literal>js_preread</literal></link>. |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
690 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
691 |
2570
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
692 <tag-name id="s_error"><literal>s.error(<value>string</value>)</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
693 <tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
694 writes a sent <literal>string</literal> to the error log |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
695 on the <literal>error</literal> level of logging |
2877
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
696 <para> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
697 <note> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
698 As nginx has a |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
699 <link doc="../dev/development_guide.xml" id="logging">hardcoded</link> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
700 maximum line length limit, |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
701 only first 2048 bytes of the string can be logged. |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
702 </note> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
703 </para> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
704 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
705 |
2570
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
706 <tag-name id="s_log"><literal>s.log(<value>string</value>)</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
707 <tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
708 writes a sent <value>string</value> to the error log |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
709 on the <literal>info</literal> level of logging |
2877
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
710 <para> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
711 <note> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
712 As nginx has a |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
713 <link doc="../dev/development_guide.xml" id="logging">hardcoded</link> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
714 maximum line length limit, |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
715 only first 2048 bytes of the string can be logged. |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
716 </note> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
717 </para> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
718 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
719 |
2881
e59e8645055d
Relocated note from s.off to s.log in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2877
diff
changeset
|
720 <tag-name id="s_off"><literal>s.off(<value>eventName</value>)</literal></tag-name> |
e59e8645055d
Relocated note from s.off to s.log in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2877
diff
changeset
|
721 <tag-desc> |
e59e8645055d
Relocated note from s.off to s.log in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2877
diff
changeset
|
722 unregisters the callback set by the <link id="s_on">s.on()</link> method |
e59e8645055d
Relocated note from s.off to s.log in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2877
diff
changeset
|
723 (<link doc="changes.xml" id="njs0.2.4">0.2.4</link>) |
e59e8645055d
Relocated note from s.off to s.log in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2877
diff
changeset
|
724 </tag-desc> |
e59e8645055d
Relocated note from s.off to s.log in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2877
diff
changeset
|
725 |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
726 <tag-name id="s_on"><literal>s.on(<value>event</value>, |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
727 <value>callback</value>)</literal></tag-name> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
728 <tag-desc> |
2579
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
729 registers a <literal>callback</literal> |
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
730 for the specified <literal>event</literal> |
2337
867fe207f13e
Updated links to changes.xml in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
731 (<link doc="changes.xml" id="njs0.2.4">0.2.4</link>). |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
732 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
733 <para> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
734 An <literal>event</literal> may be one of the following strings: |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
735 <list type="tag"> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
736 <tag-name><literal>upload</literal></tag-name> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
737 <tag-desc> |
2628 | 738 new data (string) from a client |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
739 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
740 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
741 <tag-name><literal>download</literal></tag-name> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
742 <tag-desc> |
2628 | 743 new data (string) to a client |
744 </tag-desc> | |
745 | |
746 <tag-name><literal>upstream</literal></tag-name> | |
747 <tag-desc> | |
748 new data (Buffer) from a client | |
749 (since <link doc="changes.xml" id="njs0.5.0">0.5.0</link>) | |
750 </tag-desc> | |
751 | |
752 <tag-name><literal>downstream</literal></tag-name> | |
753 <tag-desc> | |
754 new data (Buffer) to a client | |
755 (since <link doc="changes.xml" id="njs0.5.0">0.5.0</link>) | |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
756 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
757 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
758 </list> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
759 </para> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
760 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
761 <para> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
762 The completion callback has the following prototype: |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
763 <literal>callback(data, flags)</literal>, where |
2628 | 764 <literal>data</literal> is string or Buffer (depending on the event type) |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
765 <literal>flags</literal> is an object |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
766 with the following properties: |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
767 <list type="tag"> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
768 <tag-name id="s_on_callback_last"><literal>last</literal></tag-name> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
769 <tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
770 a boolean value, true if data is a last buffer. |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
771 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
772 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
773 </list> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
774 </para> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
775 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
776 |
2570
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
777 <tag-name id="s_remote_address"><literal>s.remoteAddress</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
778 <tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
779 client address, read-only |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
780 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
781 |
2628 | 782 <tag-name id="s_raw_variables"><literal>s.rawVariables</literal></tag-name> |
783 <tag-desc> | |
784 nginx <link id="s_variables">variables</link> as Buffers, | |
785 writable | |
786 (since <link doc="changes.xml" id="njs0.5.0">0.5.0</link>) | |
787 </tag-desc> | |
788 | |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
789 <tag-name id="s_send"><literal>s.send(<value>data</value>[, |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
790 <value>options</value>])</literal></tag-name> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
791 <tag-desc> |
2667
2085eb315672
Updated description of s.send in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2666
diff
changeset
|
792 adds data to the chain of data chunks that will be forwarded in |
2085eb315672
Updated description of s.send in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2666
diff
changeset
|
793 the forward direction: |
2085eb315672
Updated description of s.send in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2666
diff
changeset
|
794 in download callback to a client; in upload to an upstream server |
2337
867fe207f13e
Updated links to changes.xml in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
795 (<link doc="changes.xml" id="njs0.2.4">0.2.4</link>). |
2667
2085eb315672
Updated description of s.send in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2666
diff
changeset
|
796 The actual forwarding happens later, |
2085eb315672
Updated description of s.send in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2666
diff
changeset
|
797 when the all the data chunks of the current chain are processed. |
2085eb315672
Updated description of s.send in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2666
diff
changeset
|
798 <para> |
2628 | 799 The data can be a string or Buffer |
800 (<link doc="changes.xml" id="njs0.5.0">0.5.0</link>). | |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
801 The <literal>options</literal> is an object used |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
802 to override nginx buffer flags derived from an incoming data chunk buffer. |
2579
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
803 The flags can be overridden with the following flags: |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
804 <list type="tag"> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
805 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
806 <tag-name><literal>last</literal></tag-name> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
807 <tag-desc> |
2579
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
808 boolean, |
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
809 true if the buffer is the last buffer |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
810 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
811 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
812 <tag-name><literal>flush</literal></tag-name> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
813 <tag-desc> |
2579
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
814 boolean, |
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
815 true if the buffer should have the <literal>flush</literal> flag |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
816 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
817 </list> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
818 </para> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
819 The method can be called multiple times per callback invocation. |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
820 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
821 |
2902
843bf979dcaa
Added s.sendDownstream and s.sendUpstream to njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2894
diff
changeset
|
822 <tag-name id="s_send_downstream"><literal>s.sendDownstream()</literal></tag-name> |
843bf979dcaa
Added s.sendDownstream and s.sendUpstream to njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2894
diff
changeset
|
823 <tag-desc> |
843bf979dcaa
Added s.sendDownstream and s.sendUpstream to njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2894
diff
changeset
|
824 is identical to <link id="s_send">s.send()</link>, |
843bf979dcaa
Added s.sendDownstream and s.sendUpstream to njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2894
diff
changeset
|
825 except for it always sends data to a client |
843bf979dcaa
Added s.sendDownstream and s.sendUpstream to njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2894
diff
changeset
|
826 (since <link doc="changes.xml" id="njs0.7.8">0.7.8</link>). |
843bf979dcaa
Added s.sendDownstream and s.sendUpstream to njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2894
diff
changeset
|
827 </tag-desc> |
843bf979dcaa
Added s.sendDownstream and s.sendUpstream to njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2894
diff
changeset
|
828 |
843bf979dcaa
Added s.sendDownstream and s.sendUpstream to njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2894
diff
changeset
|
829 <tag-name id="s_send_upstream"><literal>s.sendUpstream()</literal></tag-name> |
843bf979dcaa
Added s.sendDownstream and s.sendUpstream to njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2894
diff
changeset
|
830 <tag-desc> |
843bf979dcaa
Added s.sendDownstream and s.sendUpstream to njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2894
diff
changeset
|
831 is identical to <link id="s_send">s.send()</link>, |
843bf979dcaa
Added s.sendDownstream and s.sendUpstream to njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2894
diff
changeset
|
832 except for it always sends data from a client |
843bf979dcaa
Added s.sendDownstream and s.sendUpstream to njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2894
diff
changeset
|
833 (since <link doc="changes.xml" id="njs0.7.8">0.7.8</link>). |
843bf979dcaa
Added s.sendDownstream and s.sendUpstream to njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2894
diff
changeset
|
834 </tag-desc> |
843bf979dcaa
Added s.sendDownstream and s.sendUpstream to njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2894
diff
changeset
|
835 |
2665
529114f1108a
Documented s.status property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2663
diff
changeset
|
836 <tag-name id="s_status"><literal>s.status</literal></tag-name> |
529114f1108a
Documented s.status property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2663
diff
changeset
|
837 <tag-desc> |
529114f1108a
Documented s.status property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2663
diff
changeset
|
838 session status code, an alias to the |
529114f1108a
Documented s.status property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2663
diff
changeset
|
839 <link doc="../stream/ngx_stream_core_module.xml" id="var_status"><literal>$status</literal></link> |
529114f1108a
Documented s.status property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2663
diff
changeset
|
840 variable, |
529114f1108a
Documented s.status property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2663
diff
changeset
|
841 read only |
529114f1108a
Documented s.status property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2663
diff
changeset
|
842 (since <link doc="changes.xml" id="njs0.5.2">0.5.2</link>) |
529114f1108a
Documented s.status property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2663
diff
changeset
|
843 </tag-desc> |
529114f1108a
Documented s.status property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2663
diff
changeset
|
844 |
2800
3a146e49f9d4
Corrected syntax of r.setReturnValue and s.setReturnValue.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2792
diff
changeset
|
845 <tag-name id="s_set_return_value"><literal>s.setReturnValue(<value>value</value>)</literal></tag-name> |
2777
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
846 <tag-desc> |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
847 sets the return value of the |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
848 <link doc="../stream/ngx_stream_js_module.xml" id="js_set"/> handler |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
849 (<link doc="changes.xml" id="njs0.7.0">0.7.0</link>). |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
850 Unlike an ordinary return statement, |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
851 this method should be used when the handler is JS async function. |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
852 For example: |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
853 <example> |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
854 async function js_set(r) { |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
855 const digest = await crypto.subtle.digest('SHA-256', r.headersIn.host); |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
856 r.setReturnValue(digest); |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
857 } |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
858 </example> |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
859 </tag-desc> |
bc79ab31073a
Documented r.setReturnValue and s.setReturnValue in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2775
diff
changeset
|
860 |
2338
39ac205f90b7
Documented that r.variables{} and s.variables{} are writable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2337
diff
changeset
|
861 <tag-name id="s_variables"><literal>s.variables{}</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
862 <tag-desc> |
2338
39ac205f90b7
Documented that r.variables{} and s.variables{} are writable.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2337
diff
changeset
|
863 nginx variables object, writable |
2689
7e271437f12e
Updated writable variables info in r.variables and s.variables.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2688
diff
changeset
|
864 (since <link doc="changes.xml" id="njs0.2.8">0.2.8</link>). |
7e271437f12e
Updated writable variables info in r.variables and s.variables.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2688
diff
changeset
|
865 A variable can be writable only |
7e271437f12e
Updated writable variables info in r.variables and s.variables.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2688
diff
changeset
|
866 if it is referenced in nginx configuration file. |
7e271437f12e
Updated writable variables info in r.variables and s.variables.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2688
diff
changeset
|
867 Even so, some embedded variables still cannot be assigned a value. |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
868 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
869 |
2570
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
870 <tag-name id="s_warn"><literal>s.warn(<value>string</value>)</literal></tag-name> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
871 <tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
872 writes a sent <literal>string</literal> to the error log |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
873 on the <literal>warning</literal> level of logging |
2877
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
874 <para> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
875 <note> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
876 As nginx has a |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
877 <link doc="../dev/development_guide.xml" id="logging">hardcoded</link> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
878 maximum line length limit, |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
879 only first 2048 bytes of the string can be logged. |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
880 </note> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
881 </para> |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
882 </tag-desc> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
883 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
884 </list> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
885 </para> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
886 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
887 </section> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
888 |
2628 | 889 |
2653
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
890 <section id="response" name="Response"> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
891 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
892 <para> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
893 The <literal>Response</literal> interface is available since |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
894 <link doc="changes.xml" id="njs0.5.1">0.5.1</link>. |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
895 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
896 <list type="tag"> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
897 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
898 <tag-name id="response_arraybuffer"><literal>arrayBuffer()</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
899 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
900 Takes a <literal>Response</literal> stream and reads it to completion. |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
901 Returns a <literal>Promise</literal> that resolves with |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
902 an <literal>ArrayBuffer</literal>. |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
903 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
904 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
905 <tag-name id="response_bodyused"><literal>bodyUsed</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
906 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
907 A boolean value, <literal>true</literal> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
908 if the body was read. |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
909 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
910 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
911 <tag-name id="response_headers"><literal>headers</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
912 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
913 The <literal>Headers</literal> read-only object associated with the |
2668
e067ad74b0cd
Corrected links to Response Object in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2667
diff
changeset
|
914 <link id="response"><literal>Response</literal></link>: |
2653
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
915 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
916 <list type="tag"> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
917 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
918 <tag-name id="headers_get"><literal>get(<value>name</value>)</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
919 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
920 returns a string containing the values of all headers with the specified name |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
921 separated by a comma and a space |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
922 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
923 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
924 <tag-name id="headers_getall"><literal>getAll(<value>name</value>)</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
925 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
926 returns an array containing the values of all headers with the specified name |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
927 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
928 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
929 <tag-name id="headers_has"><literal>has(<value>name</value>)</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
930 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
931 returns a boolean value |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
932 indicating whether a header with the specified name exists |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
933 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
934 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
935 </list> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
936 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
937 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
938 <tag-name id="response_json"><literal>json()</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
939 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
940 Takes a <literal>Response</literal> stream and reads it to completion. |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
941 Returns a <literal>Promise</literal> that resolves with |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
942 the result of parsing the body text as JSON. |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
943 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
944 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
945 <tag-name id="response_ok"><literal>ok</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
946 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
947 A boolean value, <literal>true</literal> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
948 if the response was successful (status codes between 200–299). |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
949 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
950 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
951 <tag-name id="response_redirect"><literal>redirected</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
952 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
953 A boolean value, <literal>true</literal> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
954 if the response is the result of a redirect. |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
955 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
956 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
957 <tag-name id="response_status"><literal>status</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
958 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
959 The status code of the response. |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
960 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
961 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
962 <tag-name id="response_statustext"><literal>statusText</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
963 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
964 The status message corresponding to the status code. |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
965 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
966 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
967 <tag-name id="response_text"><literal>text()</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
968 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
969 Takes a <literal>Response</literal> stream and reads it to completion. |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
970 Returns a <literal>Promise</literal> that resolves with a string. |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
971 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
972 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
973 <tag-name id="response_type"><literal>type</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
974 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
975 The type of the response. |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
976 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
977 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
978 <tag-name id="response_url"><literal>url</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
979 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
980 The URL of the response. |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
981 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
982 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
983 </list> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
984 </para> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
985 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
986 </section> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
987 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
988 |
2628 | 989 <section id="ngx" name="ngx"> |
990 | |
991 <para> | |
992 The <literal>ngx</literal> global object is available | |
993 since <link doc="changes.xml" id="njs0.5.0">0.5.0</link>. | |
994 <list type="tag"> | |
995 | |
2653
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
996 <tag-name id="ngx_fetch"><literal>ngx.fetch(<value>url</value>, |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
997 [<value>options</value>])</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
998 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
999 Makes a request to fetch an URL |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1000 (<link doc="changes.xml" id="njs0.5.1">0.5.1</link>), |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1001 returns a <literal>Promise</literal> that resolves with |
2668
e067ad74b0cd
Corrected links to Response Object in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2667
diff
changeset
|
1002 the <link id="response"><literal>Response</literal></link> object. |
2774
7255a5468474
Documented HTTPS support for ngx_fetch.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2735
diff
changeset
|
1003 Since <link doc="changes.xml" id="njs0.7.0">0.7.0</link>, |
7255a5468474
Documented HTTPS support for ngx_fetch.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2735
diff
changeset
|
1004 the <literal>https://</literal> scheme is supported, |
2653
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1005 redirects are not handled. |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1006 <para> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1007 The <literal>options</literal> parameter is expected to be an object |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1008 with the following keys: |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1009 <list type="tag"> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1010 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1011 <tag-name id="fetch_body"><literal>body</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1012 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1013 request body, |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1014 by default is empty |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1015 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1016 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1017 <tag-name id="fetch_buffer_size"><literal>buffer_size</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1018 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1019 the buffer size for reading the response, |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1020 by default is <literal>4096</literal> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1021 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1022 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1023 <tag-name id="fetch_headers"><literal>headers</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1024 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1025 request headers object |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1026 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1027 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1028 <tag-name id="fetch_get"><literal>max_response_body_size</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1029 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1030 the maximum size of the response body in bytes, |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1031 by default is <literal>32768</literal> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1032 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1033 |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1034 <tag-name id="fetch_method"><literal>method</literal></tag-name> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1035 <tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1036 HTTP method, |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1037 by default the <literal>GET</literal> method is used |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1038 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1039 |
2775
9ce9239c6b7b
Documented "verify" key in ngx_fetch.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2774
diff
changeset
|
1040 <tag-name id="fetch_verify"><literal>verify</literal></tag-name> |
9ce9239c6b7b
Documented "verify" key in ngx_fetch.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2774
diff
changeset
|
1041 <tag-desc> |
9ce9239c6b7b
Documented "verify" key in ngx_fetch.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2774
diff
changeset
|
1042 enables or disables verification of the HTTPS server certificate, |
9ce9239c6b7b
Documented "verify" key in ngx_fetch.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2774
diff
changeset
|
1043 by default is <literal>true</literal> |
9ce9239c6b7b
Documented "verify" key in ngx_fetch.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2774
diff
changeset
|
1044 (<link doc="changes.xml" id="njs0.7.0">0.7.0</link>) |
9ce9239c6b7b
Documented "verify" key in ngx_fetch.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2774
diff
changeset
|
1045 </tag-desc> |
9ce9239c6b7b
Documented "verify" key in ngx_fetch.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2774
diff
changeset
|
1046 |
2653
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1047 </list> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1048 Example: |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1049 <example> |
2840
3b705c0a5af7
Updated example for ngx.fetch in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2818
diff
changeset
|
1050 let reply = await ngx.fetch('http://nginx.org/'); |
3b705c0a5af7
Updated example for ngx.fetch in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2818
diff
changeset
|
1051 let body = await reply.text(); |
3b705c0a5af7
Updated example for ngx.fetch in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2818
diff
changeset
|
1052 |
3b705c0a5af7
Updated example for ngx.fetch in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2818
diff
changeset
|
1053 r.return(200, body); |
2653
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1054 </example> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1055 </para> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1056 </tag-desc> |
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1057 |
2628 | 1058 <tag-name id="ngx_log"><literal>ngx.log</literal>(<value>level</value>, |
1059 <value>message</value>)</tag-name> | |
1060 <tag-desc> | |
1061 Writes a message to the error log with the specified level of logging. | |
1062 The <value>level</value> parameter specifies one of the log levels, | |
1063 the <value>message</value> parameter can be a string or Buffer. | |
1064 The following log levels can be specified: | |
1065 <literal>ngx.INFO</literal>, | |
1066 <literal>ngx.WARN</literal>, and | |
1067 <literal>ngx.ERR</literal>. | |
2877
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
1068 <para> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
1069 <note> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
1070 As nginx has a |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
1071 <link doc="../dev/development_guide.xml" id="logging">hardcoded</link> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
1072 maximum line length limit, |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
1073 only first 2048 bytes of the string can be logged. |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
1074 </note> |
0280b6c71d38
Added note about string length to log methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2873
diff
changeset
|
1075 </para> |
2628 | 1076 </tag-desc> |
2653
9fc25ea7a92c
Documented ngx.fetch and Response interface in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2647
diff
changeset
|
1077 |
2628 | 1078 </list> |
1079 </para> | |
1080 | |
1081 </section> | |
1082 | |
2247
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
1083 </section> |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
1084 |
0f16ef9a8dbe
Created "nginx objects" section in reference.xml.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2246
diff
changeset
|
1085 |
2687
7ff9d8bda757
Revised TOC in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2685
diff
changeset
|
1086 <section id="builtin_objects" name="built-in objects"> |
2405
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
1087 |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
1088 |
2783
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1089 <section id="builtin_crypto" name="crypto"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1090 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1091 <para> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1092 The <literal>crypto</literal> object is a global object |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1093 that allows using cryptographic functionality |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1094 (since <link doc="changes.xml" id="njs0.7.0">0.7.0</link>). |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1095 </para> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1096 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1097 <para> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1098 <list type="tag"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1099 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1100 <tag-name id="crypto_get_random_values"><literal>сrypto.getRandomValues</literal>(<link id="crypto_get_random_values_array"><literal>typedArray</literal></link>)</tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1101 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1102 Gets cryptographically strong random values. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1103 Returns the same array passed as <literal>typedArray</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1104 but with its contents replaced with the newly generated random numbers. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1105 Possible values: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1106 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1107 <list type="tag"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1108 <tag-name id="crypto_get_random_values_array"><literal>typedArray</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1109 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1110 can be |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1111 <literal>Int8Array</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1112 <literal>Int16Array</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1113 <literal>Uint16Array</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1114 <literal>Int32Array</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1115 <literal>Uint32Array</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1116 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1117 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1118 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1119 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1120 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1121 <tag-name id="crypto_subtle_encrypt"><literal>сrypto.subtle.encrypt</literal>(<link id="crypto_encrypt_alg"><literal>algorithm</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1122 <link id="crypto_encrypt_key"><literal>key</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1123 <link id="crypto_encrypt_data"><literal>data</literal></link>)</tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1124 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1125 Encrypts <link id="crypto_encrypt_data"><literal>data</literal></link> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1126 using the provided |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1127 <link id="crypto_encrypt_algorithm"><literal>algorithm</literal></link> and |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1128 <link id="crypto_encrypt_key"><literal>key</literal></link>. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1129 Returns a <literal>Promise</literal> that fulfills with |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1130 an <literal>ArrayBuffer</literal> containing the ciphertext. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1131 Possible values: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1132 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1133 <list type="tag"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1134 <tag-name id="crypto_encrypt_alg"><literal>algorithm</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1135 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1136 an object that specifies |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1137 the algorithm to be used and any extra parameters if required: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1138 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1139 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1140 <listitem id="rsa_oaep_params"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1141 for <literal>RSA-OAEP</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1142 pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1143 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1144 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1145 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1146 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1147 <literal>name</literal> is a string, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1148 should be set to <literal>RSA-OAEP</literal>: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1149 <para> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1150 <example> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1151 crypto.subtle.encrypt({name: "RSA-OAEP"}, key, data) |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1152 </example> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1153 </para> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1154 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1155 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1156 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1157 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1158 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1159 <listitem id="aes_ctr_params"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1160 for <literal>AES-CTR</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1161 pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1162 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1163 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1164 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1165 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1166 <literal>name</literal> is a string, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1167 should be set to <literal>AES-CTR</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1168 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1169 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1170 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1171 <literal>counter</literal> is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1172 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1173 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1174 <literal>DataView</literal> — |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1175 the initial value of the counter block, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1176 must be 16 bytes long (the AES block size). |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1177 The rightmost length bits of this block are used for the counter, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1178 and the rest is used for the nonce. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1179 For example, if length is set to 64, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1180 then the first half of counter is the nonce |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1181 and the second half is used for the counter |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1182 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1183 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1184 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1185 <literal>length</literal> is the number of bits in the counter block |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1186 that are used for the actual counter. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1187 The counter must be big enough that it doesn't wrap. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1188 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1189 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1190 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1191 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1192 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1193 <listitem id="aes_cbc_params"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1194 for <literal>AES-CBC</literal>, pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1195 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1196 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1197 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1198 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1199 <literal>name</literal> is a string, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1200 should be set to <literal>AES-CBC</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1201 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1202 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1203 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1204 <literal>iv</literal> or the initialization vector, is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1205 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1206 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1207 <literal>DataView</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1208 must be 16 bytes, unpredictable, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1209 and preferably cryptographically random. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1210 However, it need not be secret, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1211 for example, it may be transmitted unencrypted along with the ciphertext. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1212 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1213 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1214 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1215 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1216 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1217 <listitem id="aes_gcm_params"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1218 for <literal>AES-GCM</literal>, pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1219 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1220 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1221 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1222 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1223 <literal>name</literal> is a string, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1224 should be set to <literal>AES-GCM</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1225 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1226 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1227 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1228 <literal>iv</literal> or the initialization vector, is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1229 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1230 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1231 <literal>DataView</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1232 must be 16 bytes, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1233 and must be unique for every encryption operation carried out with a given key |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1234 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1235 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1236 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1237 <literal>additionalData</literal> (optional) is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1238 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1239 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1240 <literal>DataView</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1241 that contains additional data that |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1242 will not be encrypted but will be authenticated along with the encrypted data. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1243 If <literal>additionalData</literal> is specified, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1244 then the same data must be specified in the corresponding call to |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1245 <literal>decrypt()</literal>: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1246 if the data given to the <literal>decrypt()</literal> call |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1247 does not match the original data, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1248 the decryption will throw an exception. |
2792
c6713b6b86ce
Removed trailing spaces.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2783
diff
changeset
|
1249 The bit length of <literal>additionalData</literal> |
2783
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1250 must be smaller than <literal>2^64 - 1</literal>. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1251 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1252 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1253 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1254 <literal>tagLength</literal> (optional, default is <literal>128</literal>) - |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1255 a <literal>number</literal> that determines the size in bits |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1256 of the authentication tag generated in the encryption operation |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1257 and used for authentication in the corresponding decryption |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1258 Possible values: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1259 <literal>32</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1260 <literal>64</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1261 <literal>96</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1262 <literal>104</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1263 <literal>112</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1264 <literal>120</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1265 <literal>128</literal>. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1266 The AES-GCM specification recommends that it should be |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1267 <literal>96</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1268 <literal>104</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1269 <literal>112</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1270 <literal>120</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1271 <literal>128</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1272 although |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1273 <literal>32</literal> or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1274 <literal>64</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1275 bits may be acceptable in some applications. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1276 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1277 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1278 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1279 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1280 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1281 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1282 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1283 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1284 <tag-name id="crypto_encrypt_key"><literal>key</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1285 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1286 a <literal>CryptoKey</literal> that contains |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1287 the key to be used for encryption |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1288 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1289 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1290 <tag-name id="crypto_encrypt_data"><literal>data</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1291 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1292 an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1293 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1294 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1295 <literal>DataView</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1296 that contains |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1297 the data to be encrypted (also known as the plaintext) |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1298 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1299 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1300 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1301 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1302 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1303 <tag-name id="crypto_subtle_decrypt"><literal>сrypto.subtle.decrypt</literal>(<link id="crypto_decrypt_alg"><literal>algorithm</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1304 <link id="crypto_decrypt_key"><literal>key</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1305 <link id="crypto_decrypt_data"><literal>data</literal></link>)</tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1306 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1307 Decrypts encrypted data. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1308 Returns a <literal>Promise</literal> with the decrypted data. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1309 Possible values: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1310 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1311 <list type="tag"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1312 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1313 <tag-name id="crypto_decrypt_alg"><literal>algorithm</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1314 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1315 an object |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1316 that specifies the algorithm to be used, and any extra parameters as required. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1317 The values given for the extra parameters must match |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1318 those passed into the corresponding <literal>encrypt()</literal> call. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1319 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1320 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1321 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1322 for <literal>RSA-OAEP</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1323 pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1324 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1325 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1326 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1327 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1328 <literal>name</literal> is a string, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1329 should be set to <literal>RSA-OAEP</literal>: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1330 <para> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1331 <example> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1332 crypto.subtle.encrypt({name: "RSA-OAEP"}, key, data) |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1333 </example> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1334 </para> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1335 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1336 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1337 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1338 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1339 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1340 for <literal>AES-CTR</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1341 pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1342 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1343 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1344 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1345 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1346 <literal>name</literal> is a string, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1347 should be set to <literal>AES-CTR</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1348 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1349 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1350 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1351 <literal>counter</literal> is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1352 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1353 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1354 <literal>DataView</literal> — |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1355 the initial value of the counter block, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1356 must be 16 bytes long (the AES block size). |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1357 The rightmost length bits of this block are used for the counter, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1358 and the rest is used for the nonce. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1359 For example, if length is set to 64, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1360 then the first half of counter is the nonce |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1361 and the second half is used for the counter. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1362 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1363 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1364 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1365 <literal>length</literal> is the number of bits in the counter block |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1366 that are used for the actual counter. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1367 The counter must be big enough that it doesn't wrap. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1368 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1369 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1370 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1371 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1372 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1373 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1374 for <literal>AES-CBC</literal>, pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1375 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1376 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1377 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1378 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1379 <literal>name</literal> is a string, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1380 should be set to <literal>AES-CBC</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1381 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1382 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1383 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1384 <literal>iv</literal> or the initialization vector, is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1385 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1386 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1387 <literal>DataView</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1388 must be 16 bytes, unpredictable, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1389 and preferably cryptographically random. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1390 However, it need not be secret |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1391 (for example, it may be transmitted unencrypted along with the ciphertext). |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1392 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1393 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1394 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1395 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1396 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1397 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1398 for <literal>AES-GCM</literal>, pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1399 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1400 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1401 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1402 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1403 <literal>name</literal> is a string, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1404 should be set to <literal>AES-GCM</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1405 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1406 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1407 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1408 <literal>iv</literal> or the initialization vector, is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1409 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1410 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1411 <literal>DataView</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1412 must be 16 bytes, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1413 and must be unique for every encryption operation carried out with a given key |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1414 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1415 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1416 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1417 <literal>additionalData</literal> (optional) is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1418 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1419 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1420 <literal>DataView</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1421 that contains additional data that |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1422 will not be encrypted but will be authenticated along with the encrypted data. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1423 If <literal>additionalData</literal> is specified, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1424 then the same data must be specified in the corresponding call to |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1425 <literal>decrypt()</literal>: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1426 if the data given to the <literal>decrypt()</literal> call |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1427 does not match the original data, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1428 the decryption will throw an exception. |
2792
c6713b6b86ce
Removed trailing spaces.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2783
diff
changeset
|
1429 The bit length of <literal>additionalData</literal> |
2783
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1430 must be smaller than <literal>2^64 - 1</literal>. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1431 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1432 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1433 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1434 <literal>tagLength</literal> (optional, default is <literal>128</literal>) - |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1435 a <literal>number</literal> that determines the size in bits |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1436 of the authentication tag generated in the encryption operation |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1437 and used for authentication in the corresponding decryption. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1438 Possible values: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1439 <literal>32</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1440 <literal>64</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1441 <literal>96</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1442 <literal>104</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1443 <literal>112</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1444 <literal>120</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1445 <literal>128</literal>. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1446 The AES-GCM specification recommends that it should be |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1447 <literal>96</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1448 <literal>104</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1449 <literal>112</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1450 <literal>120</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1451 <literal>128</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1452 although |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1453 <literal>32</literal> or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1454 <literal>64</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1455 bits may be acceptable in some applications. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1456 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1457 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1458 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1459 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1460 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1461 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1462 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1463 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1464 <tag-name id="crypto_decrypt_key"><literal>key</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1465 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1466 a <literal>CryptoKey</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1467 that contains the key to be used for decryption. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1468 If <literal>RSA-OAEP</literal> is used, this is the |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1469 <literal>privateKey</literal> property of the |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1470 <literal>CryptoKeyPair</literal> object. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1471 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1472 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1473 <tag-name id="crypto_decrypt_data"><literal>data</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1474 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1475 an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1476 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1477 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1478 <literal>DataView</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1479 that contains the data to be decrypted (also known as ciphertext) |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1480 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1481 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1482 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1483 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1484 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1485 <tag-name id="crypto_subtle_derive_bits"><literal>сrypto.subtle.deriveBits</literal>(<link id="crypto_derive_bits_alg"><literal>algorithm</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1486 <link id="crypto_derive_bits_basekey"><literal>baseKey</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1487 <link id="crypto_derive_bits_length"><literal>length</literal></link>)</tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1488 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1489 Derives an array of bits from a base key. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1490 Returns a <literal>Promise</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1491 which will be fulfilled with an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1492 <literal>ArrayBuffer</literal> that contains the derived bits. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1493 Possible values: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1494 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1495 <list type="tag"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1496 <tag-name id="crypto_derive_bits_alg"><literal>algorithm</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1497 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1498 is an object that defines the derivation algorithm to use: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1499 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1500 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1501 <listitem id="hkdf_params"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1502 for <literal>HKDF</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1503 pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1504 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1505 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1506 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1507 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1508 <literal>name</literal> is a string, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1509 should be set to <literal>HKDF</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1510 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1511 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1512 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1513 <literal>hash</literal> is a string with the digest algorithm to use: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1514 <literal>SHA-1</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1515 <literal>SHA-256</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1516 <literal>SHA-384</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1517 <literal>SHA-512</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1518 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1519 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1520 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1521 <literal>salt</literal> is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1522 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1523 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1524 <literal>DataView</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1525 that represents random or pseudo-random value |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1526 with the same length as the output of the <literal>digest</literal> function. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1527 Unlike the input key material passed into <literal>deriveKey()</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1528 salt does not need to be kept secret. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1529 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1530 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1531 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1532 <literal>info</literal> is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1533 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1534 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1535 <literal>DataView</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1536 that represents application-specific contextual information |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1537 used to bind the derived key to an application or context, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1538 and enables deriving different keys for different contexts |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1539 while using the same input key material. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1540 This property is required but may be an empty buffer. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1541 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1542 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1543 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1544 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1545 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1546 <listitem id="pbkdf2_params"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1547 for <literal>PBKDF2</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1548 pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1549 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1550 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1551 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1552 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1553 <literal>name</literal> is a string, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1554 should be set to <literal>PBKDF2</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1555 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1556 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1557 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1558 <literal>hash</literal> is a string with the digest algorithm to use: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1559 <literal>SHA-1</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1560 <literal>SHA-256</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1561 <literal>SHA-384</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1562 <literal>SHA-512</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1563 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1564 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1565 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1566 <literal>salt</literal> is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1567 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1568 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1569 <literal>DataView</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1570 that represents random or pseudo-random value |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1571 of at least <literal>16</literal> bytes. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1572 Unlike the input key material passed into <literal>deriveKey()</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1573 salt does not need to be kept secret. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1574 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1575 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1576 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1577 <literal>iterations</literal> is a <literal>number</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1578 that represents the number of times the hash function will be executed |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1579 in <literal>deriveKey()</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1580 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1581 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1582 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1583 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1584 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1585 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1586 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1587 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1588 <tag-name id="crypto_derive_bits_basekey"><literal>baseKey</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1589 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1590 is a <literal>CryptoKey</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1591 that represents the input to the derivation algorithm |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1592 - the initial key material for the derivation function: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1593 for example, for <literal>PBKDF2</literal> it might be a password, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1594 imported as a <literal>CryptoKey</literal> using |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1595 <link id="crypto_subtle_import_key"><literal>сrypto.subtle.importKey()</literal></link> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1596 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1597 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1598 <tag-name id="crypto_derive_bits_length"><literal>length</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1599 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1600 is a number representing the number of bits to derive. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1601 For browsers compatibility, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1602 the number should be a multiple of <literal>8</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1603 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1604 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1605 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1606 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1607 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1608 <tag-name id="crypto_subtle_derive_key"><literal>сrypto.subtle.deriveKey</literal>(<link id="crypto_derive_key_alg"><literal>algorithm</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1609 <link id="crypto_derive_key_basekey"><literal>baseKey</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1610 <link id="crypto_derive_key_derivedkeyalg"><literal>derivedKeyAlgorithm</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1611 <link id="crypto_derive_key_extractable"><literal>extractable</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1612 <link id="crypto_derive_key_keyusages"><literal>keyUsages</literal></link>)</tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1613 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1614 Derives a secret key from a master key. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1615 Possible values: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1616 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1617 <list type="tag"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1618 <tag-name id="crypto_derive_key_alg"><literal>algorithm</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1619 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1620 is an object that defines the derivation algorithm to use: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1621 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1622 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1623 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1624 for <literal>HKDF</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1625 pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1626 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1627 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1628 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1629 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1630 <literal>name</literal> is a string, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1631 should be set to <literal>HKDF</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1632 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1633 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1634 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1635 <literal>hash</literal> is a string with the digest algorithm to use: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1636 <literal>SHA-1</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1637 <literal>SHA-256</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1638 <literal>SHA-384</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1639 <literal>SHA-512</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1640 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1641 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1642 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1643 <literal>salt</literal> is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1644 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1645 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1646 <literal>DataView</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1647 that represents random or pseudo-random value |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1648 with the same length as the output of the <literal>digest</literal> function. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1649 Unlike the input key material passed into <literal>deriveKey()</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1650 salt does not need to be kept secret. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1651 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1652 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1653 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1654 <literal>info</literal> is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1655 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1656 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1657 <literal>DataView</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1658 that represents application-specific contextual information |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1659 used to bind the derived key to an application or context, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1660 and enables deriving different keys for different contexts |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1661 while using the same input key material. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1662 This property is required but may be an empty buffer. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1663 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1664 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1665 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1666 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1667 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1668 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1669 for <literal>PBKDF2</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1670 pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1671 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1672 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1673 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1674 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1675 <literal>name</literal> is a string, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1676 should be set to <literal>PBKDF2</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1677 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1678 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1679 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1680 <literal>hash</literal> is a string with the digest algorithm to use: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1681 <literal>SHA-1</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1682 <literal>SHA-256</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1683 <literal>SHA-384</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1684 <literal>SHA-512</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1685 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1686 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1687 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1688 <literal>salt</literal> is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1689 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1690 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1691 <literal>DataView</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1692 that represents random or pseudo-random value |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1693 of at least <literal>16</literal> bytes. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1694 Unlike the input key material passed into <literal>deriveKey()</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1695 salt does not need to be kept secret. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1696 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1697 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1698 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1699 <literal>iterations</literal> is a <literal>number</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1700 that represents the number of times the hash function will be executed |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1701 in <literal>deriveKey()</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1702 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1703 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1704 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1705 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1706 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1707 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1708 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1709 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1710 <tag-name id="crypto_derive_key_basekey"><literal>baseKey</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1711 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1712 is a <literal>CryptoKey</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1713 that represents the input to the derivation algorithm |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1714 - the initial key material for the derivation function: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1715 for example, for <literal>PBKDF2</literal> it might be a password, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1716 imported as a <literal>CryptoKey</literal> using |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1717 <link id="crypto_sublte_import_key"><literal>сrypto.subtle.importKey()</literal></link>. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1718 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1719 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1720 <tag-name id="crypto_derive_key_derivedkeyalg"><literal>derivedKeyAlgorithm</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1721 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1722 is an object |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1723 that defines the algorithm the derived key will be used for: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1724 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1725 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1726 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1727 for <literal>HMAC</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1728 pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1729 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1730 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1731 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1732 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1733 <literal>name</literal> is a string, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1734 should be set to <literal>HMAC</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1735 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1736 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1737 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1738 <literal>hash</literal> is a string with the name of the digest function to use: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1739 <literal>SHA-1</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1740 <literal>SHA-256</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1741 <literal>SHA-384</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1742 <literal>SHA-512</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1743 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1744 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1745 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1746 <literal>length</literal> (optional) is a <literal>number</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1747 that represents the length in bits of the key. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1748 If not specified, the length of the key is equal to |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1749 the block size of the chozen hash function |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1750 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1751 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1752 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1753 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1754 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1755 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1756 for |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1757 <literal>AES-CTR</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1758 <literal>AES-CBC</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1759 <literal>AES-GCM</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1760 pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1761 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1762 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1763 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1764 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1765 <literal>name</literal> is a string, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1766 should be set to |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1767 <literal>AES-CTR</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1768 <literal>AES-CBC</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1769 <literal>AES-GCM</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1770 depending on the algorithm used |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1771 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1772 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1773 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1774 <literal>length</literal> is a <literal>number</literal> that represents |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1775 the length in bits of the key to generate: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1776 <literal>128</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1777 <literal>192</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1778 <literal>256</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1779 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1780 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1781 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1782 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1783 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1784 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1785 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1786 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1787 <tag-name id="crypto_derive_key_extractable"><literal>extractable</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1788 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1789 is a boolean value |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1790 that indicates whether it will be possible to export the key |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1791 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1792 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1793 <tag-name id="crypto_derive_key_keyusages"><literal>keyUsages</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1794 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1795 is an <literal>Array</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1796 that indicates what can be done with the derived key. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1797 The key usages must be allowed by the algorithm |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1798 set in <literal>derivedKeyAlgorithm</literal>. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1799 Possible values: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1800 <list type="tag"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1801 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1802 <tag-name><literal>encrypt</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1803 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1804 key for encrypting messages |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1805 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1806 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1807 <tag-name><literal>decrypt</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1808 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1809 key for decrypting messages |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1810 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1811 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1812 <tag-name><literal>sign</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1813 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1814 key for signing messages |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1815 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1816 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1817 <tag-name><literal>verify</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1818 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1819 key for verifying signatures |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1820 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1821 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1822 <tag-name><literal>deriveKey</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1823 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1824 key for deriving a new key |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1825 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1826 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1827 <tag-name><literal>deriveBits</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1828 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1829 key for deriving bits |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1830 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1831 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1832 <tag-name><literal>wrapKey</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1833 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1834 key for wrapping a key |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1835 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1836 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1837 <tag-name><literal>unwrapKey</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1838 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1839 key for unwrapping a key |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1840 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1841 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1842 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1843 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1844 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1845 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1846 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1847 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1848 <tag-name id="crypto_subtle_digest"><literal>сrypto.subtle.digest</literal>(<link id="crypto_digest_alg"><literal>algorithm</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1849 <link id="crypto_digest_data"><literal>data</literal></link>)</tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1850 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1851 Generates a digest of the given data. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1852 Takes as its arguments an identifier for the digest algorithm to use |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1853 and the data to digest. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1854 Returns a <literal>Promise</literal> which will be fulfilled with the digest. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1855 Possible values: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1856 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1857 <list type="tag"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1858 <tag-name id="crypto_digest_alg"><literal>algorithm</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1859 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1860 is a string that defines the hash function to use: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1861 <literal>SHA-1</literal> (not for cryptographic applications), |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1862 <literal>SHA-256</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1863 <literal>SHA-384</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1864 <literal>SHA-512</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1865 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1866 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1867 <tag-name id="crypto_digest_data"><literal>data</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1868 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1869 is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1870 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1871 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1872 <literal>DataView</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1873 that contains the data to be digested |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1874 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1875 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1876 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1877 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1878 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1879 <tag-name id="crypto_subtle_import_key"><literal>сrypto.subtle.importKey</literal>(<link id="crypto_import_key_format"><literal>format</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1880 <link id="crypto_import_key_keydata"><literal>keyData</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1881 <link id="crypto_import_key_alg"><literal>algorithm</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1882 <link id="crypto_import_key_extractable"><literal>extractable</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1883 <link id="crypto_import_key_keyusages"><literal>keyUsages</literal></link>)</tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1884 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1885 Imports a key: takes as input a key in an external, portable format |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1886 and gives a <literal>CryptoKey</literal> object. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1887 Returns a <literal>Promise</literal> that fulfills with the imported key |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1888 as a <literal>CryptoKey</literal> object. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1889 Possible values: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1890 <list type="tag"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1891 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1892 <tag-name id="crypto_import_key_format"><literal>format</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1893 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1894 a string that describes the data format of the key to import, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1895 can be the following: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1896 <list type="tag"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1897 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1898 <tag-name><literal>raw</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1899 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1900 the raw data format |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1901 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1902 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1903 <tag-name><literal>pkcs8</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1904 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1905 the |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1906 <link url="https://datatracker.ietf.org/doc/html/rfc5208">PKCS #8</link> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1907 format |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1908 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1909 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1910 <tag-name><literal>spki</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1911 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1912 the |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1913 <link url=" https://datatracker.ietf.org/doc/html/rfc5280#section-4.1">SubjectPublicKeyInfo</link> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1914 format |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1915 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1916 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1917 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1918 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1919 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1920 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1921 <tag-name id="crypto_import_key_keydata"><literal>keyData</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1922 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1923 the |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1924 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1925 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1926 <literal>DataView</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1927 object that contains the key in the given format |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1928 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1929 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1930 <tag-name id="crypto_import_key_alg"><literal>algorithm</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1931 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1932 a dictionary object that defines the type of key to import |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1933 and provides extra algorithm-specific parameters: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1934 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1935 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1936 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1937 for |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1938 <literal>RSASSA-PKCS1-v1_5</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1939 <literal>RSA-PSS</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1940 <literal>RSA-OAEP</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1941 pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1942 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1943 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1944 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1945 <literal>name</literal> is a string, should be set to |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1946 <literal>RSASSA-PKCS1-v1_5</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1947 <literal>RSA-PSS</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1948 <literal>RSA-OAEP</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1949 depending on the used algorithm |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1950 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1951 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1952 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1953 <literal>hash</literal> is a string that represents |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1954 the name of the <literal>digest</literal> function to use, can be |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1955 <literal>SHA-256</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1956 <literal>SHA-384</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1957 <literal>SHA-512</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1958 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1959 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1960 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1961 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1962 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1963 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1964 for |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1965 <literal>ECDSA</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1966 pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1967 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1968 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1969 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1970 <literal>name</literal> is a string, should be set to <literal>ECDSA</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1971 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1972 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1973 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1974 <literal>namedCurve</literal> is a string that represents |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1975 the name of the elliptic curve to use, may be |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1976 <literal>P-256</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1977 <literal>P-384</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1978 <literal>P-521</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1979 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1980 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1981 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1982 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1983 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1984 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1985 for |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1986 <literal>HMAC</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1987 pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1988 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1989 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1990 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1991 <literal>name</literal> is a string, should be set to <literal>HMAC</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1992 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1993 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1994 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1995 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1996 <literal>hash</literal> is a string that represents |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1997 the name of the <literal>digest</literal> function to use, can be |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1998 <literal>SHA-256</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
1999 <literal>SHA-384</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2000 <literal>SHA-512</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2001 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2002 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2003 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2004 <literal>length</literal> (optional) is a number that represents |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2005 the length in bits of the key. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2006 If omitted, the length of the key is equal to the length of the digest |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2007 generated by the chosen digest function. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2008 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2009 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2010 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2011 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2012 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2013 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2014 for |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2015 <literal>AES-CTR</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2016 <literal>AES-CBC</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2017 <literal>AES-GCM</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2018 pass the string identifying the algorithm or an object |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2019 of the form <literal>{ "name": "ALGORITHM" }</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2020 where <literal>ALGORITHM</literal> is the name of the algorithm |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2021 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2022 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2023 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2024 for |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2025 <literal>PBKDF2</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2026 pass the <literal>PBKDF2</literal> string |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2027 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2028 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2029 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2030 for |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2031 <literal>HKDF</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2032 pass the <literal>HKDF</literal> string |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2033 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2034 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2035 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2036 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2037 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2038 <tag-name id="crypto_import_key_extractable"><literal>extractable</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2039 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2040 boolean value that indicates if it is possible to export the key |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2041 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2042 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2043 <tag-name id="crypto_import_key_keyusages"><literal>keyUsages</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2044 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2045 an <literal>array</literal> that indicates possible actions with the key: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2046 <list type="tag"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2047 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2048 <tag-name><literal>encrypt</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2049 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2050 key for encrypting messages |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2051 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2052 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2053 <tag-name><literal>decrypt</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2054 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2055 key for decrypting messages |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2056 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2057 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2058 <tag-name><literal>sign</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2059 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2060 key for signing messages |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2061 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2062 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2063 <tag-name><literal>verify</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2064 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2065 key for verifying signatures |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2066 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2067 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2068 <tag-name><literal>deriveKey</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2069 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2070 key for deriving a new key |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2071 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2072 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2073 <tag-name><literal>deriveBits</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2074 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2075 key for deriving bits |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2076 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2077 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2078 <tag-name><literal>wrapKey</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2079 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2080 key for wrapping a key |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2081 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2082 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2083 <tag-name><literal>unwrapKey</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2084 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2085 key for unwrapping a key |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2086 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2087 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2088 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2089 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2090 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2091 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2092 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2093 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2094 <tag-name id="crypto_subtle_sign"><literal>сrypto.subtle.sign</literal>(<link id="crypto_sign_alg"><literal>algorithm</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2095 <link id="crypto_sign_key"><literal>key</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2096 <link id="crypto_sign_data"><literal>data</literal></link>)</tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2097 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2098 Returns <literal>signature</literal> as a <literal>Promise</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2099 that fulfills with an <literal>ArrayBuffer</literal> containing the signature. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2100 Possible values: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2101 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2102 <list type="tag"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2103 <tag-name id="crypto_sign_alg"><literal>algorithm</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2104 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2105 is a string or object that specifies the signature algorithm to use |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2106 and its parameters: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2107 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2108 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2109 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2110 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2111 for <literal>RSASSA-PKCS1-v1_5</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2112 pass the string identifying the algorithm or an object |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2113 of the form <literal>{ "name": "ALGORITHM" }</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2114 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2115 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2116 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2117 for <literal>RSA-PSS</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2118 pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2119 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2120 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2121 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2122 <literal>name</literal> is a string, should be set to |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2123 <literal>RSA-PSS</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2124 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2125 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2126 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2127 <literal>saltLength</literal> is a long <literal>integer</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2128 that represents the length of the random salt to use, in bytes |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2129 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2130 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2131 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2132 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2133 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2134 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2135 for <literal>ECDSA</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2136 pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2137 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2138 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2139 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2140 <literal>name</literal> is a string, should be set to |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2141 <literal>ECDSA</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2142 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2143 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2144 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2145 <literal>hash</literal> is an identifier for the digest algorithm to use, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2146 can be |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2147 <literal>SHA-256</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2148 <literal>SHA-384</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2149 <literal>SHA-512</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2150 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2151 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2152 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2153 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2154 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2155 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2156 for <literal>HMAC</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2157 pass the string identifying the algorithm or an object |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2158 of the form <literal>{ "name": "ALGORITHM" }</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2159 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2160 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2161 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2162 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2163 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2164 <tag-name id="crypto_sign_key"><literal>key</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2165 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2166 is a <literal>CryptoKey</literal> object that the key to be used for signing. |
2792
c6713b6b86ce
Removed trailing spaces.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2783
diff
changeset
|
2167 If algorithm identifies a public-key cryptosystem, this is the private key. |
2783
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2168 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2169 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2170 <tag-name id="crypto_sign_data"><literal>data</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2171 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2172 is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2173 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2174 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2175 <literal>DataView</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2176 object that contains the data to be signed |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2177 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2178 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2179 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2180 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2181 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2182 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2183 <tag-name id="crypto_subtle_verify"><literal>сrypto.subtle.verify</literal>(<link id="crypto_verify_alg"><literal>algorithm</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2184 <link id="crypto_verify_key"><literal>key</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2185 <link id="crypto_verify_signature"><literal>signature</literal></link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2186 <link id="crypto_verify_data"><literal>data</literal></link>)</tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2187 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2188 Verifies a digital signature, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2189 returns a <literal>Promise</literal> that fulfills with a boolean value: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2190 <literal>true</literal> if the signature is valid, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2191 otherwise <literal>false</literal>. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2192 Possible values: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2193 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2194 <list type="tag"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2195 <tag-name id="crypto_verify_alg"><literal>algorithm</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2196 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2197 is a string or object that specifies the algorithm to use |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2198 and its parameters: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2199 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2200 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2201 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2202 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2203 for <literal>RSASSA-PKCS1-v1_5</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2204 pass the string identifying the algorithm or an object |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2205 of the form <literal>{ "name": "ALGORITHM" }</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2206 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2207 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2208 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2209 for <literal>RSA-PSS</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2210 pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2211 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2212 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2213 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2214 <literal>name</literal> is a string, should be set to |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2215 <literal>RSA-PSS</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2216 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2217 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2218 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2219 <literal>saltLength</literal> is a long <literal>integer</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2220 that represents the length of the random salt to use, in bytes |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2221 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2222 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2223 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2224 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2225 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2226 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2227 for <literal>ECDSA</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2228 pass the object with the following keys: |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2229 <list type="bullet"> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2230 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2231 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2232 <literal>name</literal> is a string, should be set to |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2233 <literal>ECDSA</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2234 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2235 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2236 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2237 <literal>hash</literal> is an identifier for the digest algorithm to use, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2238 can be |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2239 <literal>SHA-256</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2240 <literal>SHA-384</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2241 <literal>SHA-512</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2242 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2243 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2244 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2245 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2246 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2247 <listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2248 for <literal>HMAC</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2249 pass the string identifying the algorithm or an object |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2250 of the form <literal>{ "name": "ALGORITHM" }</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2251 </listitem> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2252 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2253 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2254 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2255 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2256 <tag-name id="crypto_verify_key"><literal>key</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2257 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2258 is a <literal>CryptoKey</literal> object that the key to be used for verifying. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2259 It is the secret key for a symmetric algorithm |
2792
c6713b6b86ce
Removed trailing spaces.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2783
diff
changeset
|
2260 and the public key for a public-key system. |
2783
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2261 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2262 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2263 <tag-name id="crypto_verify_signature"><literal>signature</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2264 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2265 is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2266 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2267 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2268 <literal>DataView</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2269 that contains the signature to verify |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2270 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2271 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2272 <tag-name id="crypto_verify_data"><literal>data</literal></tag-name> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2273 <tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2274 is an |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2275 <literal>ArrayBuffer</literal>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2276 <literal>TypedArray</literal>, or |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2277 <literal>DataView</literal> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2278 object that contains the data whose signature is to be verified |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2279 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2280 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2281 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2282 </tag-desc> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2283 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2284 </list> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2285 </para> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2286 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2287 </section> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2288 |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
2289 |
2666
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2290 <section id="njs" name="njs"> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2291 |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2292 <para> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2293 The <literal>njs</literal> object is a global object |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2294 that represents the current VM instance |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2295 (since <link doc="changes.xml" id="njs0.2.0">0.2.0</link>). |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2296 </para> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2297 |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2298 <para> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2299 <list type="tag"> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2300 |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2301 <tag-name id="njs_version"><literal>njs.version</literal></tag-name> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2302 <tag-desc> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2303 Returns a string with the current version of njs |
2847
f5e49925e9db
Documented the njs.version_number property in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2840
diff
changeset
|
2304 (for example, “0.7.4”). |
f5e49925e9db
Documented the njs.version_number property in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2840
diff
changeset
|
2305 </tag-desc> |
f5e49925e9db
Documented the njs.version_number property in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2840
diff
changeset
|
2306 |
f5e49925e9db
Documented the njs.version_number property in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2840
diff
changeset
|
2307 <tag-name id="njs_version_number"><literal>njs.version_number</literal></tag-name> |
f5e49925e9db
Documented the njs.version_number property in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2840
diff
changeset
|
2308 <tag-desc> |
f5e49925e9db
Documented the njs.version_number property in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2840
diff
changeset
|
2309 Returns a number with the current version of njs. |
f5e49925e9db
Documented the njs.version_number property in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2840
diff
changeset
|
2310 For example, “0.7.4” is returned as <literal>0x000704</literal> |
f5e49925e9db
Documented the njs.version_number property in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2840
diff
changeset
|
2311 (since <link doc="changes.xml" id="njs0.7.4">0.7.4</link>). |
2666
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2312 </tag-desc> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2313 |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2314 <tag-name id="njs_dump"><literal>njs.dump(<value>value</value>)</literal></tag-name> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2315 <tag-desc> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2316 Returns the pretty-print string representation for a value. |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2317 </tag-desc> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2318 |
2904
4aaab86a9c26
Added the njs.memoryStats property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2902
diff
changeset
|
2319 <tag-name id="njs_memory_stats"><literal>njs.memoryStats</literal></tag-name> |
4aaab86a9c26
Added the njs.memoryStats property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2902
diff
changeset
|
2320 <tag-desc> |
4aaab86a9c26
Added the njs.memoryStats property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2902
diff
changeset
|
2321 Object containing memory statistics for current VM instance |
4aaab86a9c26
Added the njs.memoryStats property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2902
diff
changeset
|
2322 (since <link doc="changes.xml" id="njs0.7.8">0.7.8</link>). |
4aaab86a9c26
Added the njs.memoryStats property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2902
diff
changeset
|
2323 <list type="tag"> |
4aaab86a9c26
Added the njs.memoryStats property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2902
diff
changeset
|
2324 |
4aaab86a9c26
Added the njs.memoryStats property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2902
diff
changeset
|
2325 <tag-name><literal>size</literal></tag-name> |
4aaab86a9c26
Added the njs.memoryStats property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2902
diff
changeset
|
2326 <tag-desc> |
4aaab86a9c26
Added the njs.memoryStats property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2902
diff
changeset
|
2327 amount of memory in bytes njs memory pool claimed from the operating system. |
4aaab86a9c26
Added the njs.memoryStats property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2902
diff
changeset
|
2328 </tag-desc> |
4aaab86a9c26
Added the njs.memoryStats property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2902
diff
changeset
|
2329 |
4aaab86a9c26
Added the njs.memoryStats property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2902
diff
changeset
|
2330 </list> |
4aaab86a9c26
Added the njs.memoryStats property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2902
diff
changeset
|
2331 </tag-desc> |
4aaab86a9c26
Added the njs.memoryStats property in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2902
diff
changeset
|
2332 |
2679
8f3e9ff2785f
Corrected syntax of njs.on() and ngx.fetch() in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2670
diff
changeset
|
2333 <tag-name id="njs_on"><literal>njs.on(<value>event</value>, |
8f3e9ff2785f
Corrected syntax of njs.on() and ngx.fetch() in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2670
diff
changeset
|
2334 <value>callback</value>)</literal></tag-name> |
2666
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2335 <tag-desc> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2336 Registers a callback for the specified VM event |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2337 (since <link doc="changes.xml" id="njs0.5.2">0.5.2</link>). |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2338 An event may be one of the following strings: |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2339 <list type="tag"> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2340 |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2341 <tag-name><literal>exit</literal></tag-name> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2342 <tag-desc> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2343 is called before the VM is destroyed. |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2344 The callback is called without arguments. |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2345 </tag-desc> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2346 |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2347 </list> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2348 </tag-desc> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2349 |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2350 </list> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2351 </para> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2352 |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2353 </section> |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2354 |
68c0566a375f
Documented njs global object in njs Refernce.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2665
diff
changeset
|
2355 |
2687
7ff9d8bda757
Revised TOC in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2685
diff
changeset
|
2356 <section id="process" name="process"> |
2405
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2357 |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2358 <para> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2359 The <literal>process</literal> object is a global object |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2360 that provides information about the current process |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2361 (<link doc="changes.xml" id="njs0.3.3">0.3.3</link>). |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2362 </para> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2363 |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2364 <para> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2365 <list type="tag"> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2366 |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2367 <tag-name id="process_argv"><literal>process.argv</literal></tag-name> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2368 <tag-desc> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2369 Returns an array that contains the command line arguments |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2370 passed when the current process was launched. |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2371 </tag-desc> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2372 |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2373 <tag-name id="process_env"><literal>process.env</literal></tag-name> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2374 <tag-desc> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2375 Returns an object containing the user environment. |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2376 <note> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2377 By default, nginx removes all environment variables inherited |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2378 from its parent process except the TZ variable. |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2379 Use the <link doc="../ngx_core_module.xml" id="env"/> directive |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2380 to preserve some of the inherited variables. |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2381 </note> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2382 </tag-desc> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2383 |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2384 <tag-name id="process_pid"><literal>process.pid</literal></tag-name> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2385 <tag-desc> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2386 Returns the PID of the current process. |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2387 </tag-desc> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2388 |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2389 <tag-name id="process_ppid"><literal>process.ppid</literal></tag-name> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2390 <tag-desc> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2391 Returns the PID of the current parent process. |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2392 </tag-desc> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2393 |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2394 </list> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2395 </para> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2396 |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2397 </section> |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2398 |
dbf68c949522
Documented the "process" global object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2394
diff
changeset
|
2399 |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2400 <section id="string" name="String"> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2401 |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2402 <para> |
2315
ae56e4613280
Corrected language in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2313
diff
changeset
|
2403 There are two types of strings in njs: a Unicode string (default) and |
ae56e4613280
Corrected language in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2313
diff
changeset
|
2404 a byte string. |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2405 </para> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2406 |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2407 <para> |
2315
ae56e4613280
Corrected language in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2313
diff
changeset
|
2408 A Unicode string corresponds to an ECMAScript string |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2409 which contains Unicode characters. |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2410 </para> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2411 |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2412 <para> |
2315
ae56e4613280
Corrected language in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2313
diff
changeset
|
2413 Byte strings contain a sequence of bytes |
ae56e4613280
Corrected language in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2313
diff
changeset
|
2414 and are used to serialize Unicode strings |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2415 to external data and deserialize from external sources. |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2416 For example, the <link id="string_toutf8">toUTF8()</link> method serializes |
2688
dd2bbd104146
Unified spelling of UTF-8 in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2687
diff
changeset
|
2417 a Unicode string to a byte string using UTF-8 encoding: |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2418 <example> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2419 >> '£'.toUTF8().toString('hex') |
2688
dd2bbd104146
Unified spelling of UTF-8 in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2687
diff
changeset
|
2420 'c2a3' /* C2 A3 is the UTF-8 representation of 00A3 ('£') code point */ |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2421 </example> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2422 The <link id="string_tobytes">toBytes()</link> method serializes |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2423 a Unicode string with code points up to 255 into a byte string, |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2424 otherwise, <literal>null</literal> is returned: |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2425 <example> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2426 >> '£'.toBytes().toString('hex') |
2214
e029f4bc7ede
Added quotes to njs examples.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2212
diff
changeset
|
2427 'a3' /* a3 is a byte equal to 00A3 ('£') code point */ |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2428 </example> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2429 |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2430 <list type="tag"> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2431 |
2211
660229c5c92f
Documented String.bytesFrom() method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2207
diff
changeset
|
2432 <tag-name id="string_bytesfrom"><literal>String.bytesFrom(<value>array</value> |
660229c5c92f
Documented String.bytesFrom() method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2207
diff
changeset
|
2433 | <value>string</value>, <value>encoding</value>)</literal></tag-name> |
660229c5c92f
Documented String.bytesFrom() method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2207
diff
changeset
|
2434 <tag-desc> |
2569
2edc64c05b0e
Removed ECMAScript methods from njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2564
diff
changeset
|
2435 Creates a byte string either from an array that contains octets, |
2315
ae56e4613280
Corrected language in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2313
diff
changeset
|
2436 or from an encoded string |
2337
867fe207f13e
Updated links to changes.xml in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
2437 (<link doc="changes.xml" id="njs0.2.3">0.2.3</link>). |
2211
660229c5c92f
Documented String.bytesFrom() method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2207
diff
changeset
|
2438 The encoding can be |
660229c5c92f
Documented String.bytesFrom() method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2207
diff
changeset
|
2439 <literal>hex</literal>, |
660229c5c92f
Documented String.bytesFrom() method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2207
diff
changeset
|
2440 <literal>base64</literal>, and |
660229c5c92f
Documented String.bytesFrom() method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2207
diff
changeset
|
2441 <literal>base64url</literal>. |
2605
0ec1e1b063d7
Deprecated String.bytesFrom method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2604
diff
changeset
|
2442 The method is deprecated since |
0ec1e1b063d7
Deprecated String.bytesFrom method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2604
diff
changeset
|
2443 <link doc="changes.xml" id="njs0.4.4">0.4.4</link>, |
0ec1e1b063d7
Deprecated String.bytesFrom method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2604
diff
changeset
|
2444 the <literal>Buffer.from</literal> method should be used instead: |
2211
660229c5c92f
Documented String.bytesFrom() method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2207
diff
changeset
|
2445 <example> |
2605
0ec1e1b063d7
Deprecated String.bytesFrom method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2604
diff
changeset
|
2446 >> Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]).toString() |
2211
660229c5c92f
Documented String.bytesFrom() method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2207
diff
changeset
|
2447 'buffer' |
660229c5c92f
Documented String.bytesFrom() method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2207
diff
changeset
|
2448 |
2605
0ec1e1b063d7
Deprecated String.bytesFrom method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2604
diff
changeset
|
2449 >> Buffer.from('YnVmZmVy', 'base64').toString() |
2211
660229c5c92f
Documented String.bytesFrom() method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2207
diff
changeset
|
2450 'buffer' |
660229c5c92f
Documented String.bytesFrom() method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2207
diff
changeset
|
2451 </example> |
660229c5c92f
Documented String.bytesFrom() method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2207
diff
changeset
|
2452 </tag-desc> |
660229c5c92f
Documented String.bytesFrom() method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2207
diff
changeset
|
2453 |
2267
c30048802769
Added links to njs reference from njs Compatibility.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2259
diff
changeset
|
2454 <tag-name id="string_frombytes"><literal>String.prototype.fromBytes(<value>start</value>[, |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2455 <value>end</value>])</literal></tag-name> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2456 <tag-desc> |
2884
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2457 the property is deprecated since |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2458 <link doc="changes.xml" id="njs0.7.7">0.7.7</link>. |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2459 Before <link doc="changes.xml" id="njs0.7.7">0.7.7</link>, |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2460 returned a new Unicode string from a byte string |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2461 where each byte was replaced with a corresponding Unicode code point. |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2462 </tag-desc> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2463 |
2267
c30048802769
Added links to njs reference from njs Compatibility.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2259
diff
changeset
|
2464 <tag-name id="string_fromutf8"><literal>String.prototype.fromUTF8(<value>start</value>[, |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2465 <value>end</value>])</literal></tag-name> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2466 <tag-desc> |
2884
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2467 the property is deprecated since |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2468 <link doc="changes.xml" id="njs0.7.7">0.7.7</link>, |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2469 the <link id="textedeoder"><literal>TextDecoder</literal></link> method |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2470 should be used instead. |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2471 Before <link doc="changes.xml" id="njs0.7.7">0.7.7</link>, |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2472 converted a byte string containing a valid UTF-8 string |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2473 into a Unicode string, |
2884
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2474 otherwise <literal>null</literal> was returned. |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2475 </tag-desc> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2476 |
2579
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
2477 <tag-name id="string_tobytes"><literal>String.prototype.toBytes(<value>start</value>[, |
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
2478 <value>end</value>])</literal></tag-name> |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2479 <tag-desc> |
2884
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2480 the property is deprecated since |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2481 <link doc="changes.xml" id="njs0.7.7">0.7.7</link>. |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2482 Before <link doc="changes.xml" id="njs0.7.7">0.7.7</link>, |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2483 serialized a Unicode string to a byte string, |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2484 returned <literal>null</literal> if a character larger than 255 was |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2485 found in the string. |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2486 </tag-desc> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2487 |
2582
e162a71453b0
Improved String.prototype.toString() for ordinary strings in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2579
diff
changeset
|
2488 <tag-name id="string_tostring"><literal>String.prototype.toString(<value>encoding</value>)</literal></tag-name> |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2489 <tag-desc> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2490 <para> |
2884
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2491 the property is deprecated since |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2492 <link doc="changes.xml" id="njs0.7.7">0.7.7</link>. |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2493 Before <link doc="changes.xml" id="njs0.7.7">0.7.7</link>, |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2494 encoded a string to |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2495 <literal>hex</literal>, |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2496 <literal>base64</literal>, or |
2582
e162a71453b0
Improved String.prototype.toString() for ordinary strings in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2579
diff
changeset
|
2497 <literal>base64url</literal>: |
e162a71453b0
Improved String.prototype.toString() for ordinary strings in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2579
diff
changeset
|
2498 <example> |
e162a71453b0
Improved String.prototype.toString() for ordinary strings in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2579
diff
changeset
|
2499 >> 'αβγδ'.toString('base64url') |
e162a71453b0
Improved String.prototype.toString() for ordinary strings in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2579
diff
changeset
|
2500 'zrHOss6zzrQ' |
e162a71453b0
Improved String.prototype.toString() for ordinary strings in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2579
diff
changeset
|
2501 </example> |
e162a71453b0
Improved String.prototype.toString() for ordinary strings in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2579
diff
changeset
|
2502 Before version <link doc="changes.xml" id="njs0.4.3">0.4.3</link>, |
e162a71453b0
Improved String.prototype.toString() for ordinary strings in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2579
diff
changeset
|
2503 only a <link id="string_tobytes">byte string</link> could be encoded: |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2504 <example> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2505 >> 'αβγδ'.toUTF8().toString('base64url') |
2214
e029f4bc7ede
Added quotes to njs examples.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2212
diff
changeset
|
2506 'zrHOss6zzrQ' |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2507 </example> |
2582
e162a71453b0
Improved String.prototype.toString() for ordinary strings in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2579
diff
changeset
|
2508 </para> |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2509 </tag-desc> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2510 |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2511 <tag-name id="string_toutf8"><literal>String.prototype.toUTF8(<value>start</value>[, |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2512 <value>end</value>])</literal></tag-name> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2513 <tag-desc> |
2884
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2514 the property is deprecated since |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2515 <link doc="changes.xml" id="njs0.7.7">0.7.7</link>, |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2516 the <link id="textencoder"><literal>TextEncoder</literal></link> method |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2517 should be used instead. |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2518 Before <link doc="changes.xml" id="njs0.7.7">0.7.7</link>, |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2519 serialized a Unicode string |
ccd42f2b99fb
Deprecated several methods in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2881
diff
changeset
|
2520 to a byte string using UTF-8 encoding: |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2521 <example> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2522 >> 'αβγδ'.toUTF8().length |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2523 8 |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2524 >> 'αβγδ'.length |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2525 4 |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2526 </example> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2527 </tag-desc> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2528 |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2529 </list> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2530 </para> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2531 |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2532 </section> |
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2533 |
2687
7ff9d8bda757
Revised TOC in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2685
diff
changeset
|
2534 </section> |
7ff9d8bda757
Revised TOC in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2685
diff
changeset
|
2535 |
7ff9d8bda757
Revised TOC in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2685
diff
changeset
|
2536 |
7ff9d8bda757
Revised TOC in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2685
diff
changeset
|
2537 <section id="webapi" name="web API"> |
7ff9d8bda757
Revised TOC in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2685
diff
changeset
|
2538 |
2186
8e2b3aadc3ce
Added njs String object.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2183
diff
changeset
|
2539 |
2585
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2540 <section id="textdecoder" name="Text Decoder"> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2541 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2542 <para> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2543 The <literal>TextDecoder</literal> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2544 produces a stream of code points |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2545 from a stream of bytes |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2546 (<link doc="changes.xml" id="njs0.4.3">0.4.3</link>). |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2547 </para> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2548 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2549 <para> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2550 <list type="tag"> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2551 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2552 <tag-name><literal>TextDecoder([[<value>encoding</value>], |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2553 <value>options</value>])</literal></tag-name> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2554 <tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2555 Creates a new <literal>TextDecoder</literal> object |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2556 for specified <literal>encoding</literal>, |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2557 currently, only UTF-8 is supported. |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2558 The <literal>options</literal> is |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2559 <literal>TextDecoderOptions</literal> dictionary with the property: |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2560 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2561 <list type="tag"> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2562 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2563 <tag-name><literal>fatal</literal></tag-name> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2564 <tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2565 boolean flag indicating if |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2566 <link id="textdecoder_decode"><literal>TextDecoder.decode()</literal></link> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2567 must throw the <value>TypeError</value> exception when |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2568 a coding error is found, by default is <literal>false</literal>. |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2569 </tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2570 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2571 </list> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2572 </tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2573 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2574 <tag-name id="textdecoder_encoding"><literal>TextDecoder.prototype.encoding</literal></tag-name> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2575 <tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2576 Returns a string with the name of the encoding used by |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2577 <link id="textdecoder"><literal>TextDecoder()</literal></link>, |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2578 read-only. |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2579 </tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2580 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2581 <tag-name id="textdecoder_fatal"><literal>TextDecoder.prototype.fatal</literal></tag-name> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2582 <tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2583 boolean flag, <literal>true</literal> if |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2584 the error mode is fatal, |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2585 read-only. |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2586 </tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2587 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2588 <tag-name id="textdecoder_ignorebom"><literal>TextDecoder.prototype.ignoreBOM</literal></tag-name> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2589 <tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2590 boolean flag, <literal>true</literal> if |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2591 the byte order marker is ignored, |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2592 read-only. |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2593 </tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2594 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2595 <tag-name id="textdecoder_decode"><literal>TextDecoder.prototype.decode(<value>buffer</value>, |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2596 [<value>options</value>])</literal></tag-name> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2597 <tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2598 Returns a string with the text |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2599 decoded from the <literal>buffer</literal> by |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2600 <link id="textdecoder"><literal>TextDecoder()</literal></link>. |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2601 The buffer can be <literal>ArrayBuffer</literal>. |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2602 The <literal>options</literal> is |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2603 <literal>TextDecodeOptions</literal> dictionary with the property: |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2604 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2605 <list type="tag"> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2606 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2607 <tag-name><literal>stream</literal></tag-name> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2608 <tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2609 boolean flag indicating if |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2610 additional data will follow in subsequent calls to <literal>decode()</literal>: |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2611 <literal>true</literal> if processing the data in chunks, and |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2612 <literal>false</literal> for the final chunk |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2613 or if the data is not chunked. |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2614 By default is <literal>false</literal>. |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2615 </tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2616 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2617 </list> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2618 <example> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2619 >> (new TextDecoder()).decode(new Uint8Array([206,177,206,178])) |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2620 αβ |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2621 </example> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2622 </tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2623 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2624 </list> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2625 </para> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2626 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2627 </section> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2628 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2629 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2630 <section id="textencoder" name="Text Encoder"> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2631 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2632 <para> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2633 The <literal>TextEncoder</literal> object |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2634 produces a byte stream with UTF-8 encoding |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2635 from a stream of code points |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2636 (<link doc="changes.xml" id="njs0.4.3">0.4.3</link>). |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2637 </para> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2638 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2639 <para> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2640 <list type="tag"> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2641 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2642 <tag-name><literal>TextEncoder()</literal></tag-name> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2643 <tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2644 Returns a newly constructed <literal>TextEncoder</literal> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2645 that will generate a byte stream with UTF-8 encoding. |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2646 </tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2647 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2648 <tag-name id="textencoder_encode"><literal>TextEncoder.prototype.encode(<value>string</value>)</literal></tag-name> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2649 <tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2650 Encodes <literal>string</literal> into a <literal>Uint8Array</literal> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2651 with UTF-8 encoded text. |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2652 </tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2653 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2654 <tag-name id="textencoder_encodeinto"><literal>TextEncoder.prototype.encodeInto(<value>string</value>, |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2655 <value>uint8Array</value>)</literal></tag-name> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2656 <tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2657 Encodes a <literal>string</literal> to UTF-8, |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2658 puts the result into destination <literal>Uint8Array</literal>, and |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2659 returns a dictionary object that shows the progress of the encoding. |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2660 The dictionary object contains two members: |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2661 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2662 <list type="tag"> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2663 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2664 <tag-name><literal>read</literal></tag-name> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2665 <tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2666 the number of UTF-16 units of code from the source <literal>string</literal> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2667 converted to UTF-8 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2668 </tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2669 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2670 <tag-name><literal>written</literal></tag-name> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2671 <tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2672 the number of bytes modified in the destination <literal>Uint8Array</literal> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2673 </tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2674 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2675 </list> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2676 </tag-desc> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2677 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2678 </list> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2679 </para> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2680 |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2681 </section> |
7035221dbe37
Documented TextDecoder and TextEncoder in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2583
diff
changeset
|
2682 |
2687
7ff9d8bda757
Revised TOC in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2685
diff
changeset
|
2683 </section> |
7ff9d8bda757
Revised TOC in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2685
diff
changeset
|
2684 |
7ff9d8bda757
Revised TOC in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2685
diff
changeset
|
2685 |
7ff9d8bda757
Revised TOC in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2685
diff
changeset
|
2686 <section id="njs_api_timers" name="timers"> |
2578
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2687 |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2688 <para> |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2689 <list type="tag"> |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2690 |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2691 <tag-name id="cleartimeout"><literal>clearTimeout(<value>timeout</value>)</literal></tag-name> |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2692 <tag-desc> |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2693 Cancels a <literal>timeout</literal> object |
2579
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
2694 created by <link id="settimeout"><literal>setTimeout()</literal></link>. |
2578
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2695 </tag-desc> |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2696 |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2697 <tag-name id="settimeout"><literal>setTimeout(<value>function</value>, |
2579
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
2698 <value>milliseconds</value>[, |
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
2699 <value>argument1</value>, |
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
2700 <value>argumentN</value>])</literal></tag-name> |
2578
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2701 <tag-desc> |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2702 Calls a <literal>function</literal> |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2703 after a specified number of <literal>milliseconds</literal>. |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2704 One or more optional <literal>arguments</literal> |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2705 can be passed to the specified function. |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2706 Returns a <literal>timeout</literal> object. |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2707 <example> |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2708 function handler(v) |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2709 { |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2710 // ... |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2711 } |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2712 |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2713 t = setTimeout(handler, 12); |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2714 |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2715 // ... |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2716 |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2717 clearTimeout(t); |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2718 </example> |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2719 </tag-desc> |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2720 |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2721 </list> |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2722 </para> |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2723 |
2873
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2724 <section id="njs_global_functions" name="Global functions"> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2725 |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2726 <para> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2727 <list type="tag"> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2728 |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2729 <tag-name id="atob"><literal>atob(<value>encodedData</value>)</literal></tag-name> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2730 <tag-desc> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2731 Decodes a string of data which has been encoded |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2732 using <literal>Base64</literal> encoding. |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2733 The <literal>encodedData</literal> parameter is a binary string |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2734 that contains Base64-encoded data. |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2735 Returns a string that contains decoded data from <literal>encodedData</literal>. |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2736 <para> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2737 The similar <link id="btoa"><literal>btoa()</literal></link> method |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2738 can be used to encode and transmit data |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2739 which may otherwise cause communication problems, |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2740 then transmit it and use the <literal>atob()</literal> method |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2741 to decode the data again. |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2742 For example, you can encode, transmit, and decode control characters |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2743 such as ASCII values <literal>0</literal> through <literal>31</literal>. |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2744 <example> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2745 const encodedData = btoa("text to encode"); // encode a string |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2746 const decodedData = atob(encodedData); // decode the string |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2747 </example> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2748 </para> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2749 </tag-desc> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2750 |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2751 <tag-name id="btoa"><literal>btoa(<value>stringToEncode</value>)</literal></tag-name> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2752 <tag-desc> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2753 Creates a Base64-encoded ASCII string from a binary string. |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2754 The <literal>stringToEncode</literal> parameter is a binary string to encode. |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2755 Returns an ASCII string containing the Base64 representation of |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2756 <literal>stringToEncode</literal>. |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2757 <para> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2758 The method can be used to encode data |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2759 which may otherwise cause communication problems, transmit it, |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2760 then use the <link id="atob"><literal>atob()</literal></link> method |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2761 to decode the data again. |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2762 For example, you can encode control characters |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2763 such as ASCII values <literal>0</literal> through <literal>31</literal>. |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2764 <example> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2765 const encodedData = btoa("text to encode"); // encode a string |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2766 const decodedData = atob(encodedData); // decode the string |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2767 </example> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2768 </para> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2769 </tag-desc> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2770 |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2771 </list> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2772 </para> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2773 |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2774 </section> |
b4eb565bbb1f
Documented atob and btoa global functions in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2872
diff
changeset
|
2775 |
2578
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2776 </section> |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2777 |
2687
7ff9d8bda757
Revised TOC in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2685
diff
changeset
|
2778 |
7ff9d8bda757
Revised TOC in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2685
diff
changeset
|
2779 <section id="builtin_modules" name="built-in modules"> |
2578
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2780 |
fafb7767c128
Restructured njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2571
diff
changeset
|
2781 |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2782 <section id="buffer" name="Buffer"> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2783 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2784 <para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2785 <list type="tag"> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2786 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2787 <tag-name id="buffer_alloc"><literal>Buffer.alloc(<value>size</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2788 <value>fill</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2789 <value>encoding</value>]]))</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2790 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2791 <para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2792 Allocates a new Buffer of a specified <value>size</value>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2793 If <value>fill</value> is not specified, the Buffer will be zero-filled. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2794 If <value>fill</value> is specified, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2795 the allocated Buffer will be initialized by calling |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2796 <link id="buf_fill"><literal>buf.fill(fill)</literal></link>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2797 If <value>fill</value> and <value>encoding</value> are specified, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2798 the allocated Buffer will be initialized by calling |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2799 <link id="buf_fill"><literal>buf.fill(fill, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2800 encoding)</literal></link>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2801 </para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2802 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2803 <para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2804 The <value>fill</value> parameter may be a |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2805 <value>string</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2806 <value>Buffer</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2807 <value>Uint8Array</value>, or |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2808 <value>integer</value>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2809 </para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2810 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2811 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2812 <tag-name id="buffer_alloc_unsafe"><literal>Buffer.allocUnsafe(<value>size</value>)</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2813 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2814 <para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2815 The same as |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2816 <link id="buffer_alloc"><literal>Buffer.alloc()</literal></link>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2817 with the difference that the memory allocated for the buffer is not initialized, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2818 the contents of the new buffer is unknown and may contain sensitive data. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2819 </para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2820 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2821 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2822 <tag-name id="buffer_bytelength"><literal>Buffer.byteLength(<value>value</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2823 <value>encoding</value>])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2824 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2825 Returns the byte length of a specified value, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2826 when encoded using <value>encoding</value>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2827 The value can be a |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2828 <literal>string</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2829 <literal>Buffer</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2830 <literal>TypedArray</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2831 <literal>DataView</literal>, or |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2832 <literal>ArrayBuffer</literal>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2833 If the value is a <value>string</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2834 the <literal>encoding</literal> parameter is its encoding, can be |
2631
7da360f50017
Unified spelling of "utf-8" in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2630
diff
changeset
|
2835 <value>utf8</value>, |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2836 <value>hex</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2837 <value>base64</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2838 <value>base64url</value>; |
2631
7da360f50017
Unified spelling of "utf-8" in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2630
diff
changeset
|
2839 by default is <value>utf8</value>. |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2840 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2841 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2842 <tag-name id="buffer_compare"><literal>Buffer.compare(<value>buffer1</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2843 <value>buffer2</value>)</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2844 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2845 Compares <value>buffer1</value> with <value>buffer2</value> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2846 when sorting arrays of Buffer instances. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2847 Returns |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2848 <literal>0</literal> if |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2849 <value>buffer1</value> is the same as <value>buffer2</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2850 <literal>1</literal> if |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2851 <value>buffer2</value> should come before <value>buffer1</value> when sorted, or |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2852 <literal>-1</literal> if |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2853 <value>buffer2</value> should come after <value>buffer1</value> when sorted. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2854 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2855 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2856 <tag-name id="buffer_concat"><literal>Buffer.concat(<value>list</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2857 <value>totalLength</value>])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2858 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2859 Returns a new Buffer |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2860 which is the result of concatenating all the Buffer instances in the list. |
2735
ff357b676c2e
Removed trailing spaces.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2716
diff
changeset
|
2861 If there are no items in the list or the total length is 0, |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2862 a new zero-length Buffer is returned. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2863 If <value>totalLength</value> is not specified, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2864 it is calculated from the Buffer instances in list by adding their lengths. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2865 If <value>totalLength</value> is specified, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2866 it is coerced to an unsigned integer. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2867 If the combined length of the Buffers in list exceeds |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2868 <value>totalLength</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2869 the result is truncated to <value>totalLength</value>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2870 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2871 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2872 <tag-name id="buffer_from_array"><literal>Buffer.from(<value>array</value>)</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2873 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2874 Allocates a new Buffer using an array of bytes |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2875 in the range <literal>0</literal> – <literal>255</literal>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2876 Array entries outside that range will be truncated. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2877 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2878 |
2612
6fdefb00858f
Documented Buffer.from(arrayBuffer) method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2609
diff
changeset
|
2879 <tag-name id="buffer_from_arraybuffer"><literal>Buffer.from(<value>arrayBuffer</value>, |
6fdefb00858f
Documented Buffer.from(arrayBuffer) method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2609
diff
changeset
|
2880 <value>byteOffset</value>[, |
6fdefb00858f
Documented Buffer.from(arrayBuffer) method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2609
diff
changeset
|
2881 <value>length</value>]])</literal></tag-name> |
6fdefb00858f
Documented Buffer.from(arrayBuffer) method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2609
diff
changeset
|
2882 <tag-desc> |
6fdefb00858f
Documented Buffer.from(arrayBuffer) method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2609
diff
changeset
|
2883 Creates a view of the <value>ArrayBuffer</value> |
6fdefb00858f
Documented Buffer.from(arrayBuffer) method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2609
diff
changeset
|
2884 without copying the underlying memory. |
6fdefb00858f
Documented Buffer.from(arrayBuffer) method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2609
diff
changeset
|
2885 The optional <value>byteOffset</value> and <value>length</value> arguments |
6fdefb00858f
Documented Buffer.from(arrayBuffer) method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2609
diff
changeset
|
2886 specify a memory range within the <value>arrayBuffer</value> |
6fdefb00858f
Documented Buffer.from(arrayBuffer) method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2609
diff
changeset
|
2887 that will be shared by the Buffer. |
6fdefb00858f
Documented Buffer.from(arrayBuffer) method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2609
diff
changeset
|
2888 </tag-desc> |
6fdefb00858f
Documented Buffer.from(arrayBuffer) method in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2609
diff
changeset
|
2889 |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2890 <tag-name id="buffer_from_buffer"><literal>Buffer.from(<value>buffer</value>)</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2891 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2892 Copies the passed buffer data onto a new Buffer instance. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2893 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2894 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2895 <tag-name id="buffer_from_object"><literal>Buffer.from(<value>object</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2896 <value>offsetOrEncoding</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2897 <value>length</value>]])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2898 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2899 For objects whose <literal>valueOf()</literal> function |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2900 returns a value not strictly equal to object, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2901 returns |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2902 <literal>Buffer.from(object.valueOf()</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2903 <literal>offsetOrEncoding</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2904 <literal>length</literal>). |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2905 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2906 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2907 <tag-name id="buffer_from_string"><literal>Buffer.from(<value>string</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2908 <value>encoding</value>])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2909 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2910 Creates a new Buffer with a <value>string</value>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2911 The <value>encoding</value> parameter identifies the character encoding |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2912 to be used when converting a string into bytes. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2913 The encoding can be |
2631
7da360f50017
Unified spelling of "utf-8" in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2630
diff
changeset
|
2914 <literal>utf8</literal>, |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2915 <literal>hex</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2916 <literal>base64</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2917 <literal>base64url</literal>; |
2631
7da360f50017
Unified spelling of "utf-8" in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2630
diff
changeset
|
2918 by default is <literal>utf8</literal>. |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2919 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2920 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2921 <tag-name id="buffer_is_buffer"><literal>Buffer.isBuffer(<value>object</value>)</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2922 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2923 A boolean value, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2924 returns <literal>true</literal> if <value>object</value> is a Buffer. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2925 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2926 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2927 <tag-name id="buffer_is_encoding"><literal>Buffer.isEncoding(<value>encoding</value>)</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2928 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2929 A boolean value, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2930 returns <literal>true</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2931 if encoding is the name of a supported character encoding. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2932 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2933 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2934 <tag-name id="buf_index"><literal>buffer[<value>index</value>]</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2935 <tag-desc> |
2647
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2936 The index operator that can be used to get and set the octet |
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2937 at position <literal>index</literal> in <literal>buffer</literal>. |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2938 The values refer to individual bytes, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2939 so the legal value range is between 0 and 255 (decimal). |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2940 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2941 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2942 <tag-name id="buf_buffer"><literal>buf.buffer</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2943 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2944 The underlying <literal>ArrayBuffer</literal> object |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2945 based on which this Buffer object is created. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2946 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2947 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2948 <tag-name id="buf_byte_offset"><literal>buf.byteOffset</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2949 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2950 An integer, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2951 specifying the <literal>byteOffset</literal> of the Buffers |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2952 underlying <literal>ArrayBuffer</literal> object. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2953 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2954 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2955 <tag-name id="buf_compare"><literal>buf.compare(<value>target</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2956 <value>targetStart</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2957 <value>targetEnd</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2958 <value>sourceStart</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2959 <value>sourceEnd</value>]]]])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2960 <tag-desc> |
2647
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2961 Compares buffer with <value>target</value> and returns a number |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2962 indicating whether buffer comes before, after, or is the same |
2647
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2963 as <value>target</value> in sort order. |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2964 Comparison is based on the actual sequence of bytes in each Buffer. |
2647
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2965 The <literal>targetStart</literal> is an integer specifying |
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2966 the offset within <value>target</value> at which to begin comparison, |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2967 by default is 0. |
2647
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2968 The <literal>targetEnd</literal> is an integer specifying |
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2969 the offset within <value>target</value> at which to end comparison, |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2970 by default is <literal>target.length</literal>. |
2647
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2971 The <literal>sourceStart</literal> is an integer specifying |
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2972 the offset within buffer at which to begin comparison, |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2973 by default is 0. |
2647
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2974 The <literal>sourceEnd</literal> is an integer specifying |
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2975 the offset within buffer at which to end comparison (not inclusive), |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2976 by default is <literal>buf.length</literal>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2977 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2978 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2979 <tag-name id="buf_copy"><literal>buf.copy(<value>target</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2980 <value>targetStart</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2981 <value>sourceStart</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2982 <value>sourceEnd</value>]]])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2983 <tag-desc> |
2647
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2984 Copies data from a region of buffer to a region in <value>target</value>, |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2985 even if the target memory region overlaps with buffer. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2986 The <literal>target</literal> parameter is a |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2987 <value>Buffer</value> or <value>Uint8Array</value> to copy into. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2988 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2989 <para> |
2647
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2990 The <literal>targetStart</literal> is an integer specifying |
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2991 the offset within target at which to begin writing, |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2992 by default is 0. |
2647
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2993 The <literal>sourceStart</literal> is an integer specifying |
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2994 the offset within buffer from which to begin copying, |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2995 by default is 0. |
2647
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2996 The <literal>sourceEnd</literal> is an integer specifying |
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
2997 the offset within buffer at which to stop copying (not inclusive) |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2998 by default is <value>buf.length</value>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
2999 </para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3000 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3001 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3002 <tag-name id="buf_equals"><literal>buf.equals(<value>otherBuffer</value>)</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3003 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3004 A boolean value, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3005 returns <literal>true</literal> if both Buffer and <value>otherBuffer</value> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3006 have exactly the same bytes. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3007 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3008 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3009 <tag-name id="buf_fill"><literal>buf.fill(<value>value</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3010 <value>offset</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3011 <value>end</value>]][, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3012 <value>encoding</value>])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3013 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3014 Fills the Buffer with the specified <value>value</value>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3015 If the <value>offset</value> and <value>end</value> are not specified, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3016 the entire Buffer will be filled. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3017 The <value>value</value> is coerced to <value>uint32</value> if it is not a |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3018 <literal>string</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3019 <literal>Buffer</literal>, or |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3020 <literal>integer</literal>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3021 If the resulting integer is greater than 255, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3022 the Buffer will be filled with <value>value</value> and 255. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3023 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3024 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3025 <tag-name id="buf_includes"><literal>buf.includes(<value>value</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3026 <value>byteOffset</value>][, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3027 <value>encoding</value>])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3028 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3029 Equivalent to |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3030 <link id="buf_indexof"><literal>buf.indexOf()</literal></link> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3031 <literal>!== -1</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3032 returns <literal>true</literal> if the <value>value</value> was found |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3033 in Buffer. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3034 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3035 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3036 <tag-name id="buf_indexof"><literal>buf.indexOf(<value>value</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3037 <value>byteOffset</value>][, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3038 <value>encoding</value>])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3039 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3040 Returns an integer which is the index of the first occurrence of |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3041 <value>value</value> in Buffer, or <value>-1</value> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3042 if Buffer does not contain value. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3043 The <value>value</value> can be a |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3044 <literal>string</literal> with specified <value>encoding</value> |
2631
7da360f50017
Unified spelling of "utf-8" in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2630
diff
changeset
|
3045 (by default <value>utf8</value>), |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3046 <literal>Buffer</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3047 <literal>Unit8Array</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3048 or a number between 0 and 255. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3049 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3050 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3051 <tag-name id="buf_lastindexof"><literal>buf.lastIndexOf(<value>value</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3052 <value>byteOffset</value>][, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3053 <value>encoding</value>])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3054 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3055 The same as |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3056 <link id="buf_indexof"><literal>buf.indexOf()</literal></link>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3057 except the last occurrence of the <value>value</value> is found |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3058 instead of the first occurrence. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3059 The <value>value</value> can be a string, Buffer, or |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3060 integer between 1 and 255. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3061 If the <value>value</value> is an empty string or empty Buffer, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3062 <literal>byteOffset</literal> will be returned. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3063 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3064 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3065 <tag-name id="buf_length"><literal>buf.length</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3066 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3067 Returns the number of bytes in Buffer. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3068 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3069 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3070 <tag-name id="buf_readintbe"><literal>buf.readIntBE(<value>offset</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3071 <value>byteLength</value>)</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3072 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3073 Reads the <value>byteLength</value> from <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3074 at the specified <value>offset</value> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3075 and interprets the result as a big-endian, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3076 two's complement signed value supporting up to 48 bits of accuracy. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3077 The <value>byteLength</value> parameter is an integer between 1 and 6 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3078 specifying the number of bytes to read. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3079 <para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3080 The similar methods are also supported: |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3081 <literal>buf.readInt8([offset])</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3082 <literal>buf.readInt16BE([offset])</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3083 <literal>buf.readInt32BE([offset])</literal>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3084 </para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3085 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3086 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3087 <tag-name id="buf_readintle"><literal>buf.readIntLE(<value>offset</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3088 <value>byteLength</value>)</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3089 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3090 Reads the <value>byteLength</value> from <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3091 at the specified <value>offset</value> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3092 and interprets the result as a little-endian, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3093 two's complement signed value supporting up to 48 bits of accuracy. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3094 The <value>byteLength</value> parameter is an integer between 1 and 6 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3095 specifying the number of bytes to read. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3096 <para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3097 The similar methods are also supported: |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3098 <literal>buf.readInt8([offset])</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3099 <literal>buf.readInt16LE([offset])</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3100 <literal>buf.readInt32LE([offset])</literal>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3101 </para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3102 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3103 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3104 <tag-name id="buf_readuintbe"><literal>buf.readUIntBE(<value>offset</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3105 <value>byteLength</value>)</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3106 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3107 Reads the <value>byteLength</value> from <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3108 at the specified <value>offset</value> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3109 and interprets the result as a big-endian |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3110 integer supporting up to 48 bits of accuracy. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3111 The <value>byteLength</value> parameter is an integer between 1 and 6 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3112 specifying the number of bytes to read. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3113 <para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3114 The similar methods are also supported: |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3115 <literal>buf.readUInt8([offset])</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3116 <literal>buf.readUInt16BE([offset])</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3117 <literal>buf.readUInt32BE([offset])</literal>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3118 </para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3119 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3120 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3121 <tag-name id="buf_readuintle"><literal>buf.readUIntLE(<value>offset</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3122 <value>byteLength</value>)</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3123 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3124 Reads the <value>byteLength</value> from <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3125 at the specified <value>offset</value> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3126 and interprets the result as a little-endian |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3127 integer supporting up to 48 bits of accuracy. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3128 The <value>byteLength</value> parameter is an integer between 1 and 6 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3129 specifying the number of bytes to read. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3130 <para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3131 The similar methods are also supported: |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3132 <literal>buf.readUInt8([offset])</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3133 <literal>buf.readUInt16LE([offset])</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3134 <literal>buf.readUInt32LE([offset])</literal>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3135 </para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3136 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3137 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3138 <tag-name id="buf_readdobulebe"><literal>buf.readDoubleBE</literal>([<value>offset</value>])</tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3139 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3140 Reads a 64-bit, big-endian double from <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3141 at the specified <value>offset</value>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3142 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3143 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3144 <tag-name id="buf_readdobulele"><literal>buf.readDoubleLE</literal>([<value>offset</value>])</tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3145 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3146 Reads a 64-bit, little-endian double from <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3147 at the specified <value>offset</value>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3148 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3149 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3150 <tag-name id="buf_readfloatbe"><literal>buf.readFloatBE</literal>([<value>offset</value>])</tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3151 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3152 Reads a 32-bit, big-endian float from <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3153 at the specified <value>offset</value>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3154 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3155 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3156 <tag-name id="buf_readfloatle"><literal>buf.readFloatLE</literal>([<value>offset</value>])</tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3157 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3158 Reads a 32-bit, little-endian float from <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3159 at the specified <value>offset</value>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3160 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3161 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3162 <tag-name id="buf_subarray"><literal>buf.subarray[<value>start</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3163 <value>end</value>]])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3164 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3165 Returns a new <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3166 that references the same memory as the original, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3167 but offset and cropped by |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3168 <value>start</value> and <value>end</value>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3169 If <value>end</value> is greater than |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3170 <link id="buf_length"><literal>buf.length</literal></link>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3171 the same result as that of end equal to |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3172 <link id="buf_length"><literal>buf.length</literal></link> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3173 is returned. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3174 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3175 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3176 <tag-name id="buf_slice"><literal>buf.slice[<value>start</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3177 <value>end</value>]])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3178 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3179 Returns a new <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3180 that references the same memory as the original, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3181 but offset and cropped by the |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3182 <value>start</value> and <value>end</value> values. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3183 The method is not compatible with the |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3184 <literal>Uint8Array.prototype.slice()</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3185 which is a superclass of Buffer. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3186 To copy the slice, use |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3187 <literal>Uint8Array.prototype.slice()</literal>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3188 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3189 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3190 <tag-name id="buf_swap16"><literal>buf.swap16</literal>()</tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3191 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3192 Interprets <literal>buf</literal> as an array of unsigned 16-bit numbers |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3193 and swaps the byte order in-place. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3194 Throws an error if |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3195 <link id="buf_length"><literal>buf.length</literal></link> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3196 is not a multiple of 2. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3197 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3198 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3199 <tag-name id="buf_swap32"><literal>buf.swap32</literal>()</tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3200 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3201 Interprets <literal>buf</literal> as an array of unsigned 32-bit numbers |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3202 and swaps the byte order in-place. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3203 Throws an error if |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3204 <link id="buf_length"><literal>buf.length</literal></link> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3205 is not a multiple of 4. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3206 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3207 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3208 <tag-name id="buf_swap64"><literal>buf.swap64</literal>()</tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3209 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3210 Interprets <literal>buf</literal> as an array of 64-bit numbers |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3211 and swaps byte order in-place. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3212 Throws an error if |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3213 <link id="buf_length"><literal>buf.length</literal></link> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3214 is not a multiple of 8. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3215 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3216 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3217 <tag-name id="buf_tojson"><literal>buf.toJSON</literal>()</tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3218 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3219 Returns a JSON representation of <literal>buf.</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3220 <literal>JSON.stringify()</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3221 implicitly calls this function when stringifying a Buffer instance. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3222 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3223 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3224 <tag-name id="buf_tostring"><literal>buf.toString([<value>encoding</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3225 <value>start</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3226 <value>end</value>]]])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3227 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3228 Decodes <literal>buf</literal> to a string |
2647
0085d9f7dc3f
Minor corrections in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2631
diff
changeset
|
3229 according to the specified character <value>encoding</value> |
2631
7da360f50017
Unified spelling of "utf-8" in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2630
diff
changeset
|
3230 which can be <value>utf8</value>, |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3231 <value>hex</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3232 <value>base64</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3233 <value>base64url</value>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3234 The <value>start</value> and <value>end</value> parameters |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3235 may be passed to decode only a subset of Buffer. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3236 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3237 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3238 <tag-name id="buf_write"><literal>buf.write(<value>string</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3239 <value>offset</value>[, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3240 <value>length</value>]][, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3241 <value>encoding</value>])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3242 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3243 Writes a <value>string</value> to <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3244 at <value>offset</value> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3245 according to the character <value>encoding</value>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3246 The <value>length</value> parameter is the number of bytes to write. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3247 If Buffer did not contain enough space to fit the entire string, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3248 only part of string will be written, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3249 however, partially encoded characters will not be written. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3250 The <value>encoding</value> can be |
2631
7da360f50017
Unified spelling of "utf-8" in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2630
diff
changeset
|
3251 <value>utf8</value>, |
2609
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3252 <value>hex</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3253 <value>base64</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3254 <value>base64url</value>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3255 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3256 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3257 <tag-name id="buf_writeintbe"><literal>buf.writeIntBE(<value>value</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3258 <value>offset</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3259 <value>byteLength</value>)</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3260 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3261 Writes <value>byteLength</value> bytes of <value>value</value> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3262 to <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3263 at the specified <value>offset</value> as big-endian. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3264 Supports up to 48 bits of accuracy. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3265 The <value>byteLength</value> parameter is an integer between 1 and 6 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3266 specifying the number of bytes to read. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3267 <para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3268 The following similar methods are also supported: |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3269 <literal>buf.writeInt8</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3270 <literal>buf.writeInt16BE</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3271 <literal>buf.writeInt32BE</literal>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3272 </para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3273 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3274 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3275 <tag-name id="buf_writeintle"><literal>buf.writeIntLE(<value>value</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3276 <value>offset</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3277 <value>byteLength</value>)</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3278 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3279 Writes <value>byteLength</value> bytes of <value>value</value> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3280 to <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3281 at the specified <value>offset</value> as little-endian. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3282 Supports up to 48 bits of accuracy. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3283 The <value>byteLength</value> parameter is an integer between 1 and 6 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3284 specifying the number of bytes to read. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3285 <para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3286 The following similar methods are also supported: |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3287 <literal>buf.writeInt8</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3288 <literal>buf.writeInt16LE</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3289 <literal>buf.writeInt32LE</literal>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3290 </para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3291 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3292 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3293 <tag-name id="buf_writeuintbe"><literal>buf.writeUIntBE(<value>value</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3294 <value>offset</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3295 <value>byteLength</value>)</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3296 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3297 Writes <value>byteLength</value> bytes of <value>value</value> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3298 to <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3299 at the specified <value>offset</value> as big-endian. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3300 Supports up to 48 bits of accuracy. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3301 The <value>byteLength</value> parameter is an integer between 1 and 6 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3302 specifying the number of bytes to read. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3303 <para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3304 The following similar methods are also supported: |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3305 <literal>buf.writeUInt8</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3306 <literal>buf.writeUInt16BE</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3307 <literal>buf.writeUInt32BE</literal>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3308 </para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3309 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3310 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3311 <tag-name id="buf_writeuintle"><literal>buf.writeUIntLE(<value>value</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3312 <value>offset</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3313 <value>byteLength</value>)</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3314 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3315 Writes <value>byteLength</value> bytes of <value>value</value> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3316 to <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3317 at the specified <value>offset</value> as little-endian. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3318 Supports up to 48 bits of accuracy. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3319 The <value>byteLength</value> parameter is an integer between 1 and 6 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3320 specifying the number of bytes to read. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3321 <para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3322 The following similar methods are also supported: |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3323 <literal>buf.writeUInt8</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3324 <literal>buf.writeUInt16LE</literal>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3325 <literal>buf.writeUInt32LE</literal>. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3326 </para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3327 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3328 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3329 <tag-name id="buf_writedoublebe"><literal>buf.writeDoubleBE(<value>value</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3330 [<value>offset</value>])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3331 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3332 Writes the <value>value</value> to <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3333 at the specified <value>offset</value> as big-endian. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3334 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3335 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3336 <tag-name id="buf_writedoublele"><literal>buf.writeDoubleLE(<value>value</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3337 [<value>offset</value>])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3338 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3339 Writes the <value>value</value> to <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3340 at the specified <value>offset</value> as little-endian. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3341 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3342 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3343 <tag-name id="buf_writefloatbe"><literal>buf.writeFloatBE(<value>value</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3344 [<value>offset</value>])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3345 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3346 Writes the <value>value</value> to <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3347 at the specified <value>offset</value> as big-endian. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3348 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3349 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3350 <tag-name id="buf_writefloatle"><literal>buf.writeFloatLE(<value>value</value>, |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3351 [<value>offset</value>])</literal></tag-name> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3352 <tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3353 Writes the <value>value</value> to <literal>buf</literal> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3354 at the specified <value>offset</value> as little-endian. |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3355 </tag-desc> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3356 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3357 </list> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3358 </para> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3359 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3360 </section> |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3361 |
99bd2ae8d2be
Added Buffer to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2605
diff
changeset
|
3362 |
2177 | 3363 <section id="crypto" name="Crypto"> |
3364 | |
3365 <para> | |
2783
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
3366 <note> |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
3367 Since <link doc="changes.xml" id="njs0.7.0">0.7.0</link>, |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
3368 extended crypto API is available as a global |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
3369 <link id="builtin_crypto">crypto</link> object. |
87713cb4be56
Documented WebCrypto API for njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2777
diff
changeset
|
3370 </note> |
2177 | 3371 The Crypto module provides cryptographic functionality support. |
3372 The Crypto module object is returned by <literal>require('crypto')</literal>. | |
3373 </para> | |
3374 | |
3375 <para> | |
3376 <list type="tag"> | |
3377 | |
2267
c30048802769
Added links to njs reference from njs Compatibility.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2259
diff
changeset
|
3378 <tag-name id="crypto_createhash"><literal>crypto.createHash(<value>algorithm</value>)</literal></tag-name> |
2177 | 3379 <tag-desc> |
3380 Creates and returns a <link id="crypto_hash">Hash</link> object | |
3381 that can be used to generate hash digests | |
3382 using the given <value>algorithm</value>. | |
2496
9dddac1420fe
Fixed typo in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2484
diff
changeset
|
3383 The algorithm can be |
2177 | 3384 <literal>md5</literal>, |
3385 <literal>sha1</literal>, and | |
3386 <literal>sha256</literal>. | |
3387 </tag-desc> | |
3388 | |
2267
c30048802769
Added links to njs reference from njs Compatibility.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2259
diff
changeset
|
3389 <tag-name id="crypto_createhmac"><literal>crypto.createHmac(<value>algorithm</value>, |
2177 | 3390 <value>secret key</value>)</literal></tag-name> |
3391 <tag-desc> | |
2579
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
3392 Creates and returns an <link id="crypto_hmac">HMAC</link> object that uses |
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
3393 the given <value>algorithm</value> and <value>secret key</value>. |
2496
9dddac1420fe
Fixed typo in njs reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2484
diff
changeset
|
3394 The algorithm can be |
2177 | 3395 <literal>md5</literal>, |
3396 <literal>sha1</literal>, and | |
3397 <literal>sha256</literal>. | |
3398 </tag-desc> | |
3399 | |
3400 </list> | |
3401 </para> | |
3402 | |
3403 | |
3404 <section id="crypto_hash" name="Hash"> | |
3405 | |
3406 <para> | |
3407 <list type="tag"> | |
3408 | |
2601 | 3409 <tag-name id="crypto_hash_update"><literal>hash.update(<value>data</value>)</literal></tag-name> |
2177 | 3410 <tag-desc> |
3411 Updates the hash content with the given <value>data</value>. | |
3412 </tag-desc> | |
3413 | |
2601 | 3414 <tag-name id="crypto_hash_digest"><literal>hash.digest([<value>encoding</value>])</literal></tag-name> |
2177 | 3415 <tag-desc> |
3416 Calculates the digest of all of the data passed using | |
3417 <literal>hash.update()</literal>. | |
3418 The encoding can be | |
3419 <literal>hex</literal>, | |
3420 <literal>base64</literal>, and | |
3421 <literal>base64url</literal>. | |
2604
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3422 If encoding is not provided, a Buffer object |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3423 (<link doc="changes.xml" id="njs0.4.4">0.4.4</link>) is returned. |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3424 <note> |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3425 Before version (<link doc="changes.xml" id="njs0.4.4">0.4.4</link>), |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3426 a byte string was returned instead of a Buffer object. |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3427 </note> |
2177 | 3428 </tag-desc> |
3429 | |
3430 </list> | |
3431 </para> | |
3432 | |
3433 <para> | |
3434 <example> | |
3435 >> var cr = require('crypto') | |
3436 undefined | |
3437 | |
3438 >> cr.createHash('sha1').update('A').update('B').digest('base64url') | |
2214
e029f4bc7ede
Added quotes to njs examples.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2212
diff
changeset
|
3439 'BtlFlCqiamG-GMPiK_GbvKjdK10' |
2177 | 3440 </example> |
3441 </para> | |
3442 | |
3443 </section> | |
3444 | |
3445 | |
3446 <section id="crypto_hmac" name="HMAC"> | |
3447 | |
3448 <para> | |
3449 <list type="tag"> | |
3450 | |
2601 | 3451 <tag-name id="crypto_hmac_update"><literal>hmac.update(<value>data</value>)</literal></tag-name> |
2177 | 3452 <tag-desc> |
3453 Updates the HMAC content with the given <value>data</value>. | |
3454 </tag-desc> | |
3455 | |
2601 | 3456 <tag-name id="crypto_hmac_digest"><literal>hmac.digest([<value>encoding</value>])</literal></tag-name> |
2177 | 3457 <tag-desc> |
3458 Calculates the HMAC digest of all of the data passed using | |
3459 <literal>hmac.update()</literal>. | |
3460 The encoding can be | |
3461 <literal>hex</literal>, | |
3462 <literal>base64</literal>, and | |
3463 <literal>base64url</literal>. | |
2604
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3464 If encoding is not provided, a Buffer object |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3465 (<link doc="changes.xml" id="njs0.4.4">0.4.4</link>) is returned. |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3466 <note> |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3467 Before version <link doc="changes.xml" id="njs0.4.4">0.4.4</link>, |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3468 a byte string was returned instead of a Buffer object. |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3469 </note> |
2177 | 3470 </tag-desc> |
3471 </list> | |
3472 </para> | |
3473 | |
3474 <para> | |
3475 <example> | |
3476 >> var cr = require('crypto') | |
3477 undefined | |
3478 | |
3479 >> cr.createHmac('sha1', 'secret.key').update('AB').digest('base64url') | |
2214
e029f4bc7ede
Added quotes to njs examples.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2212
diff
changeset
|
3480 'Oglm93xn23_MkiaEq_e9u8zk374' |
2177 | 3481 </example> |
3482 </para> | |
3483 | |
3484 </section> | |
3485 | |
3486 </section> | |
3487 | |
2204
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3488 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3489 <section id="njs_api_fs" name="File System"> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3490 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3491 <para> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3492 The File System module provides operations with files. |
2507 | 3493 </para> |
3494 | |
3495 <para> | |
2204
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3496 The module object is returned by <literal>require('fs')</literal>. |
2508
d3d5b67a1462
Language fixes in njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2507
diff
changeset
|
3497 Since <link doc="changes.xml" id="njs0.3.9">0.3.9</link>, |
d3d5b67a1462
Language fixes in njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2507
diff
changeset
|
3498 promissified versions of file system methods are available through |
2507 | 3499 <literal>require('fs').promises</literal> object: |
3500 <example> | |
3501 > var fs = require('fs').promises; | |
3502 undefined | |
3503 > fs.readFile("/file/path").then((data)=>console.log(data)) | |
3504 <file data> | |
3505 </example> | |
2204
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3506 <list type="tag"> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3507 |
2507 | 3508 <tag-name id="fs_accesssync"><literal>accessSync(<value>path</value>[, |
3509 <value>mode</value>])</literal></tag-name> | |
3510 <tag-desc> | |
3511 Synchronously tests permissions for a file or directory | |
3512 specified in the <literal>path</literal> | |
3513 (<link doc="changes.xml" id="njs0.3.9">0.3.9</link>). | |
3514 If the check fails, an error will be returned, | |
3515 otherwise, the method will return undefined. | |
3516 <list type="tag"> | |
3517 | |
3518 <tag-name><literal>mode</literal></tag-name> | |
3519 <tag-desc> | |
2887
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3520 an optional integer |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3521 that specifies the accessibility checks to be performed, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3522 by default is <link id="access_const"><literal>fs.constants.F_OK</literal></link> |
2507 | 3523 <example> |
3524 try { | |
3525 fs.accessSync('/file/path', fs.constants.R_OK | fs.constants.W_OK); | |
3526 console.log('has access'); | |
3527 } catch (e) { | |
3528 console.log('no access');) | |
3529 } | |
3530 </example> | |
3531 </tag-desc> | |
3532 | |
3533 </list> | |
3534 </tag-desc> | |
3535 | |
2570
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
3536 <tag-name id="fs_appendfilesync"><literal>appendFileSync(<value>filename</value>, |
2204
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3537 <value>data</value>[, <value>options</value>])</literal></tag-name> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3538 <tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3539 Synchronously appends specified <literal>data</literal> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3540 to a file with provided <literal>filename</literal>. |
2604
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3541 The <literal>data</literal> is expected to be a string |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3542 or a Buffer object (<link doc="changes.xml" id="njs0.4.4">0.4.4</link>). |
2204
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3543 If the file does not exist, it will be created. |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3544 The <literal>options</literal> parameter is expected to be |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3545 an object with the following keys: |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3546 <list type="tag"> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3547 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3548 <tag-name><literal>mode</literal></tag-name> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3549 <tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3550 mode option, by default is <literal>0o666</literal> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3551 </tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3552 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3553 <tag-name><literal>flag</literal></tag-name> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3554 <tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3555 file system <link id="njs_api_fs_flags">flag</link>, |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3556 by default is <literal>a</literal> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3557 </tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3558 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3559 </list> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3560 </tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3561 |
2887
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3562 <tag-name id="fs_fstatsync"><literal>fstatSync(<value>fd</value>)</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3563 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3564 Retrieves the <link id="fs_stats"><literal>fs.Stats</literal></link> object |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3565 for the file descriptor |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3566 (<link doc="changes.xml" id="njs0.7.7">0.7.7</link>). |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3567 The <literal>fd</literal> parameter is an integer |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3568 representing the file descriptor used by the method. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3569 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3570 |
2818
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3571 <tag-name id="fs_lstatsync"><literal>lstatSync(<value>path</value>[, |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3572 <value>options</value>])</literal></tag-name> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3573 <tag-desc> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3574 Synchronously retrieves |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3575 the <link id="fs_stats"><literal>fs.Stats</literal></link> object |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3576 for the symbolic link referred to by <literal>path</literal> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3577 (<link doc="changes.xml" id="njs0.7.1">0.7.1</link>). |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3578 The <literal>options</literal> parameter is expected to be |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3579 an object with the following keys: |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3580 <list type="tag"> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3581 <tag-name><literal>throwIfNoEntry</literal></tag-name> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3582 <tag-desc> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3583 a boolean value which indicates |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3584 whether an exception is thrown if no file system entry exists, |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3585 rather than returning <literal>undefined</literal>, |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3586 by default is <literal>false</literal>. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3587 </tag-desc> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3588 </list> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3589 </tag-desc> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3590 |
2563
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3591 <tag-name id="fs_mkdirsync"><literal>mkdirSync(<value>path</value>[, |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3592 <value>options</value>])</literal></tag-name> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3593 <tag-desc> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3594 Synchronously creates a directory at the specified <literal>path</literal> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3595 (<link doc="changes.xml" id="njs0.4.2">0.4.2</link>). |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3596 The <literal>options</literal> parameter is expected to be an |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3597 <literal>integer</literal> that specifies |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3598 the <link id="fs_mkdirsync_mode">mode</link>, |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3599 or an object with the following keys: |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3600 <list type="tag"> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3601 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3602 <tag-name id="fs_mkdirsync_mode"><literal>mode</literal></tag-name> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3603 <tag-desc> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3604 mode option, by default is <literal>0o777</literal>. |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3605 </tag-desc> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3606 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3607 </list> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3608 </tag-desc> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3609 |
2887
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3610 <tag-name id="fs_opensync"><literal>openSync(<value>path</value>[, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3611 <value>flags</value>[, <value>mode</value>]])</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3612 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3613 Returns an integer |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3614 representing the file descriptor for the opened file <literal>path</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3615 (<link doc="changes.xml" id="njs0.7.7">0.7.7</link>). |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3616 <list type="tag"> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3617 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3618 <tag-name><literal>flags</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3619 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3620 file system <link id="njs_api_fs_flags">flag</link>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3621 by default is <literal>r</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3622 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3623 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3624 <tag-name><literal>mode</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3625 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3626 mode option, by default is <literal>0o666</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3627 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3628 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3629 </list> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3630 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3631 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3632 <tag-name id="fs_promises_open"><literal>promises.open(<value>path</value>[, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3633 <value>flags</value>[, <value>mode</value>]])</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3634 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3635 Returns a <link id="fs_filehandle"><literal>FileHandle</literal></link> object |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3636 representing the opened file <literal>path</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3637 (<link doc="changes.xml" id="njs0.7.7">0.7.7</link>). |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3638 <list type="tag"> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3639 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3640 <tag-name><literal>flags</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3641 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3642 file system <link id="njs_api_fs_flags">flag</link>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3643 by default is <literal>r</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3644 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3645 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3646 <tag-name><literal>mode</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3647 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3648 mode option, by default is <literal>0o666</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3649 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3650 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3651 </list> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3652 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3653 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3654 <tag-name id="fs_readsync"><literal>readSync(<value>fd</value>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3655 <value>buffer</value>, <value>offset</value>[, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3656 <value>length</value>[, <value>position</value>]])</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3657 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3658 Reads the content of a file path using file descriptor <literal>fd</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3659 returns the number of bytes read |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3660 (<link doc="changes.xml" id="njs0.7.7">0.7.7</link>). |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3661 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3662 <list type="tag"> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3663 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3664 <tag-name><literal>buffer</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3665 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3666 the <literal>buffer</literal> value can be a |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3667 <literal>Buffer</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3668 <literal>TypedArray</literal>, or |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3669 <literal>DataView</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3670 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3671 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3672 <tag-name><literal>offset</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3673 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3674 is an <literal>integer</literal> representing |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3675 the position in buffer to write the data to |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3676 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3677 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3678 <tag-name><literal>length</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3679 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3680 is an <literal>integer</literal> representing |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3681 the number of bytes to read |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3682 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3683 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3684 <tag-name><literal>position</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3685 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3686 specifies where to begin reading from in the file, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3687 the value can be |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3688 <literal>integer</literal> or |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3689 <literal>null</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3690 by default is <literal>null</literal>. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3691 If <literal>position</literal> is <literal>null</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3692 data will be read from the current file position, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3693 and the file position will be updated. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3694 If position is an <literal>integer</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3695 the file position will be unchanged |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3696 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3697 </list> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3698 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3699 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3700 |
2563
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3701 <tag-name id="fs_readdirsync"><literal>readdirSync(<value>path</value>[, |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3702 <value>options</value>])</literal></tag-name> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3703 <tag-desc> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3704 Synchronously reads the contents of a directory |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3705 at the specified <literal>path</literal> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3706 (<link doc="changes.xml" id="njs0.4.2">0.4.2</link>). |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3707 The <literal>options</literal> parameter is expected to be |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3708 a string that specifies <link id="fs_readdirsync_encoding">encoding</link> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3709 or an object with the following keys: |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3710 <list type="tag"> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3711 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3712 <tag-name id="fs_readdirsync_encoding"><literal>encoding</literal></tag-name> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3713 <tag-desc> |
2604
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3714 encoding, by default is <literal>utf8</literal>. |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3715 The encoding can be <literal>utf8</literal> and <literal>buffer</literal> |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3716 (<link doc="changes.xml" id="njs0.4.4">0.4.4</link>). |
2563
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3717 </tag-desc> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3718 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3719 <tag-name id="fs_readdirsync_withfiletypes"><literal>withFileTypes</literal></tag-name> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3720 <tag-desc> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3721 if set to <literal>true</literal>, the files array will contain |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3722 <link id="fs_dirent"><literal>fs.Dirent</literal></link> objects, |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3723 by default is <literal>false</literal>. |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3724 </tag-desc> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3725 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3726 </list> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3727 </tag-desc> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3728 |
2570
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
3729 <tag-name id="fs_readfilesync"><literal>readFileSync(<value>filename</value>[, |
2204
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3730 <value>options</value>])</literal></tag-name> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3731 <tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3732 Synchronously returns the contents of the file |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3733 with provided <literal>filename</literal>. |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3734 The <literal>options</literal> parameter holds |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3735 <literal>string</literal> that specifies encoding. |
2604
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3736 If an encoding is specified, a string is returned, |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3737 otherwise, a Buffer object |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3738 (<link doc="changes.xml" id="njs0.4.4">0.4.4</link>) is returned. |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3739 <note> |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3740 Before version <link doc="changes.xml" id="njs0.4.4">0.4.4</link>, |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3741 a <link id="string_tobytes">byte string</link> was returned |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3742 if encoding was not specified. |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3743 </note> |
2204
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3744 Otherwise, <literal>options</literal> is expected to be |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3745 an object with the following keys: |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3746 <list type="tag"> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3747 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3748 <tag-name><literal>encoding</literal></tag-name> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3749 <tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3750 encoding, by default is not specified. |
2604
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3751 The encoding can be <literal>utf8</literal>, |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3752 <literal>hex</literal> |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3753 (<link doc="changes.xml" id="njs0.4.4">0.4.4</link>), |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3754 <literal>base64</literal> |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3755 (<link doc="changes.xml" id="njs0.4.4">0.4.4</link>), |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3756 <literal>base64url</literal> |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3757 (<link doc="changes.xml" id="njs0.4.4">0.4.4</link>). |
2204
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3758 </tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3759 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3760 <tag-name><literal>flag</literal></tag-name> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3761 <tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3762 file system <link id="njs_api_fs_flags">flag</link>, |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3763 by default is <literal>r</literal> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3764 </tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3765 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3766 </list> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3767 <example> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3768 >> var fs = require('fs') |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3769 undefined |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3770 >> var file = fs.readFileSync('/file/path.tar.gz') |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3771 undefined |
2604
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3772 >> var gzipped = file.slice(0,2).toString('hex') === '1f8b'; gzipped |
2204
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3773 true |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3774 </example> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3775 </tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3776 |
2507 | 3777 <tag-name id="fs_realpathsync"><literal>realpathSync(<value>path</value>[, |
3778 <value>options</value>])</literal></tag-name> | |
3779 <tag-desc> | |
3780 Synchronously computes the canonical pathname by resolving | |
3781 <literal>.</literal>, <literal>..</literal> and symbolic links using | |
2508
d3d5b67a1462
Language fixes in njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2507
diff
changeset
|
3782 <link url="http://man7.org/linux/man-pages/man3/realpath.3.html">realpath(3)</link>. |
2507 | 3783 The <literal>options</literal> argument can be a string specifying an encoding, |
3784 or an object with an encoding property specifying the character encoding | |
3785 to use for the path passed to the callback | |
3786 (<link doc="changes.xml" id="njs0.3.9">0.3.9</link>). | |
3787 </tag-desc> | |
3788 | |
2509
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3789 <tag-name id="fs_renamesync"><literal>renameSync(<value>oldPath</value>, |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3790 <value>newPath</value>)</literal></tag-name> |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3791 <tag-desc> |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3792 Synchronously changes the name or location of a file from |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3793 <literal>oldPath</literal> to <literal>newPath</literal> |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3794 (<link doc="changes.xml" id="njs0.3.4">0.3.4</link>). |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3795 <example> |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3796 >> var fs = require('fs') |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3797 undefined |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3798 >> var file = fs.renameSync('hello.txt', 'HelloWorld.txt') |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3799 undefined |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3800 </example> |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3801 </tag-desc> |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3802 |
2563
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3803 <tag-name id="fs_rmdirsync"><literal>rmdirSync(<value>path</value>)</literal></tag-name> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3804 <tag-desc> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3805 Synchronously removes a directory at the specified <literal>path</literal> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3806 (<link doc="changes.xml" id="njs0.4.2">0.4.2</link>). |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3807 </tag-desc> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3808 |
2818
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3809 <tag-name id="fs_statsync"><literal>statSync(<value>path</value>,[ |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3810 <value>options</value>])</literal></tag-name> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3811 <tag-desc> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3812 Synchronously retrieves |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3813 the <link id="fs_stats"><literal>fs.Stats</literal></link> object |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3814 for the specified <literal>path</literal> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3815 (<link doc="changes.xml" id="njs0.7.1">0.7.1</link>). |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3816 The <literal>path</literal> can be a |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3817 <literal>string</literal> or |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3818 <literal>buffer</literal>. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3819 The <literal>options</literal> parameter is expected to be |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3820 an object with the following keys: |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3821 <list type="tag"> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3822 <tag-name><literal>throwIfNoEntry</literal></tag-name> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3823 <tag-desc> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3824 a boolean value which indicates whether |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3825 an exception is thrown if no file system entry exists |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3826 rather than returning <literal>undefined</literal>, |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3827 by default is <literal>true</literal>. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3828 </tag-desc> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3829 </list> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3830 </tag-desc> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
3831 |
2509
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3832 <tag-name id="fs_symlinksync"><literal>symlinkSync(<value>target</value>, |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3833 <value>path</value>)</literal></tag-name> |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3834 <tag-desc> |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3835 Synchronously creates the link called <literal>path</literal> |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3836 pointing to <literal>target</literal> using |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3837 <link url="http://man7.org/linux/man-pages/man2/symlink.2.html">symlink(2)</link> |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3838 (<link doc="changes.xml" id="njs0.3.9">0.3.9</link>). |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3839 Relative targets are relative to the link’s parent directory. |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3840 </tag-desc> |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3841 |
2887
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3842 <tag-name id="fs_writesync_buf"><literal>writeSync(<value>fd</value>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3843 <value>buffer</value>, <value>offset</value>[, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3844 <value>length</value>[, <value>position</value>]])</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3845 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3846 Writes a buffer to a file using file descriptor, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3847 returns the <literal>number</literal> of bytes written |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3848 (<link doc="changes.xml" id="njs0.7.7">0.7.7</link>). |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3849 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3850 <list type="tag"> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3851 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3852 <tag-name><literal>fd</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3853 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3854 an <literal>integer</literal> representing the file descriptor |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3855 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3856 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3857 <tag-name><literal>buffer</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3858 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3859 the <literal>buffer</literal> value can be a |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3860 <literal>Buffer</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3861 <literal>TypedArray</literal>, or |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3862 <literal>DataView</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3863 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3864 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3865 <tag-name><literal>offset</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3866 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3867 is an <literal>integer</literal> that determines |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3868 the part of the buffer to be written, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3869 by default <literal>0</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3870 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3871 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3872 <tag-name><literal>length</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3873 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3874 is an <literal>integer</literal> specifying the number of bytes to write, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3875 by default is an offset of |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3876 <link id="buffer_bytelength">Buffer.byteLength</link> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3877 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3878 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3879 <tag-name><literal>position</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3880 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3881 refers to the offset from the beginning of the file |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3882 where this data should be written, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3883 can be an |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3884 <literal>integer</literal> or |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3885 <literal>null</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3886 by default is <literal>null</literal>. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3887 See also |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3888 <link url="https://man7.org/linux/man-pages/man2/write.2.html">pwrite(2)</link>. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3889 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3890 </list> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3891 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3892 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3893 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3894 <tag-name id="fs_writesync_str"><literal>writeSync(<value>fd</value>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3895 <value>string</value>[, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3896 <value>position</value>[, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3897 <value>encoding</value>]])</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3898 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3899 Writes a <literal>string</literal> to a file |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3900 using file descriptor <literal>fd</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3901 returns the <literal>number</literal> of bytes written |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3902 (<link doc="changes.xml" id="njs0.7.7">0.7.7</link>). |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3903 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3904 <list type="tag"> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3905 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3906 <tag-name><literal>fd</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3907 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3908 is an <literal>integer</literal> representing a file descriptor |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3909 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3910 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3911 <tag-name><literal>position</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3912 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3913 refers to the offset from the beginning of the file |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3914 where this data should be written, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3915 can be an |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3916 <literal>integer</literal> or |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3917 <literal>null</literal>, by default is <literal>null</literal>. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3918 See also |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3919 <link url="https://man7.org/linux/man-pages/man2/write.2.html">pwrite(2)</link> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3920 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3921 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3922 <tag-name><literal>encoding</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3923 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3924 is a <literal>string</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3925 by default is <literal>utf8</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3926 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3927 </list> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3928 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3929 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
3930 |
2509
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3931 <tag-name id="fs_unlinksync"><literal>unlinkSync(<value>path</value>)</literal></tag-name> |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3932 <tag-desc> |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3933 Synchronously unlinks a file by <literal>path</literal> |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3934 (<link doc="changes.xml" id="njs0.3.9">0.3.9</link>). |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3935 </tag-desc> |
827a6d7fe108
Reordered alphabetically njs file system methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2508
diff
changeset
|
3936 |
2570
44792f1ee284
Added IDs to methods in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2569
diff
changeset
|
3937 <tag-name id="fs_writefilesync"><literal>writeFileSync(<value>filename</value>, |
2204
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3938 <value>data</value>[, |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3939 <value>options</value>])</literal></tag-name> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3940 <tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3941 Synchronously writes <literal>data</literal> to a file |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3942 with provided <literal>filename</literal>. |
2604
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3943 The <literal>data</literal> is expected to be a string |
a29676472a11
Added Buffer object info to some njs methods.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2601
diff
changeset
|
3944 or a Buffer object (<link doc="changes.xml" id="njs0.4.4">0.4.4</link>). |
2204
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3945 If the file does not exist, it will be created, |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3946 if the file exists, it will be replaced. |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3947 The <literal>options</literal> parameter is expected to be |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3948 an object with the following keys: |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3949 <list type="tag"> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3950 <tag-name><literal>mode</literal></tag-name> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3951 <tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3952 mode option, by default is <literal>0o666</literal> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3953 </tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3954 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3955 <tag-name><literal>flag</literal></tag-name> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3956 <tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3957 file system <link id="njs_api_fs_flags">flag</link>, |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3958 by default is <literal>w</literal> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3959 </tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3960 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3961 </list> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3962 <example> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3963 >> var fs = require('fs') |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3964 undefined |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3965 >> var file = fs.writeFileSync('hello.txt', 'Hello world') |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3966 undefined |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3967 </example> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3968 </tag-desc> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3969 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3970 </list> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3971 </para> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3972 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
3973 |
2563
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3974 <section id="fs_dirent" name="fs.Dirent"> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3975 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3976 <para> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3977 <literal>fs.Dirent</literal> is a representation of a directory entry— |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3978 a file or a subdirectory. |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3979 When |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3980 <link id="fs_readdirsync"><literal>readdirSync()</literal></link> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3981 is called with the |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3982 <link id="fs_readdirsync_withfiletypes"><literal>withFileTypes</literal></link> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3983 option, |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3984 the resulting array contains <literal>fs.Dirent</literal> objects. |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3985 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3986 <list type= "bullet" compact="no"> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3987 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3988 <listitem> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3989 <literal>dirent.isBlockDevice()</literal>—returns |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3990 <literal>true</literal> if the <literal>fs.Dirent</literal> object describes |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3991 a block device. |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3992 </listitem> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3993 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3994 <listitem> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3995 <literal>dirent.isCharacterDevice()</literal>—returns |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3996 <literal>true</literal> if the <literal>fs.Dirent</literal> object describes |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3997 a character device. |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3998 </listitem> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
3999 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4000 <listitem> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4001 <literal>dirent.isDirectory()</literal>—returns |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4002 <literal>true</literal> if the <literal>fs.Dirent</literal> object describes |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4003 a file system directory. |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4004 </listitem> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4005 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4006 <listitem> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4007 <literal>dirent.isFIFO()</literal>—returns |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4008 <literal>true</literal> if the <literal>fs.Dirent</literal> object describes |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4009 a first-in-first-out (FIFO) pipe. |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4010 </listitem> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4011 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4012 <listitem> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4013 <literal>dirent.isFile()</literal>—returns |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4014 <literal>true</literal> if the <literal>fs.Dirent</literal> object describes |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4015 a regular file. |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4016 </listitem> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4017 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4018 <listitem> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4019 <literal>dirent.isSocket()</literal>—returns |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4020 <literal>true</literal> if the <literal>fs.Dirent</literal> object describes |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4021 a socket. |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4022 </listitem> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4023 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4024 <listitem> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4025 <literal>dirent.isSymbolicLink()</literal>—returns |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4026 <literal>true</literal> if the <literal>fs.Dirent</literal> object describes |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4027 a symbolic link. |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4028 </listitem> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4029 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4030 <listitem> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4031 <literal>dirent.name</literal>— |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4032 the name of the file <literal>fs.Dirent</literal> object refers to. |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4033 </listitem> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4034 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4035 </list> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4036 </para> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4037 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4038 </section> |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4039 |
428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2546
diff
changeset
|
4040 |
2887
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4041 <section id="fs_filehandle" name="fs.FileHandle"> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4042 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4043 <para> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4044 The <literal>FileHandle</literal> object is an object wrapper |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4045 for a numeric file descriptor |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4046 (<link doc="changes.xml" id="njs0.7.7">0.7.7</link>). |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4047 Instances of the <literal>FileHandle</literal> object are created by the |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4048 <link id="fs_promises_open"><literal>fs.promises.open()</literal></link> method. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4049 If a <literal>FileHandle</literal> is not closed using the |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4050 <link id="filehandle_close"><literal>filehandle.close()</literal></link> method, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4051 it will try to automatically close the file descriptor, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4052 helping to prevent memory leaks. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4053 Please do not rely on this behavior because it can be unreliable. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4054 Instead, always explicitly close a <literal>FileHandle</literal>. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4055 </para> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4056 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4057 <para> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4058 <list type="tag"> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4059 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4060 <tag-name id="filehandle_close"><literal>filehandle.close()</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4061 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4062 Closes the file handle after waiting for any pending operation on the handle |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4063 to complete. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4064 Returns a <literal>promise</literal>, fulfills with undefined upon success. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4065 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4066 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4067 <tag-name id="filehandle_fd"><literal>filehandle.fd</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4068 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4069 The numeric file descriptor |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4070 managed by the <literal>FileHandle</literal> object. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4071 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4072 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4073 <tag-name id="filehandle_read"><literal>filehandle.read(<value>buffer</value>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4074 <value>offset</value>[, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4075 <value>length</value>[, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4076 <value>position</value>]])</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4077 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4078 Reads data from the file and stores that in the given buffer. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4079 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4080 <list type="tag"> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4081 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4082 <tag-name><literal>buffer</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4083 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4084 a buffer that will be filled with the file data read, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4085 the value can be a |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4086 <literal>Buffer</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4087 <literal>TypedArray</literal>, or |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4088 <literal>DataView</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4089 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4090 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4091 <tag-name><literal>offset</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4092 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4093 is an <literal>integer</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4094 representing the location in the buffer at which to start filling |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4095 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4096 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4097 <tag-name><literal>length</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4098 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4099 is an <literal>integer</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4100 representing the number of bytes to read |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4101 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4102 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4103 <tag-name><literal>position</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4104 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4105 the location where to begin reading data from the file, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4106 the value can be |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4107 <literal>integer</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4108 <literal>null</literal>. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4109 If <literal>null</literal>, data will be read from the current file position |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4110 and the position will be updated. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4111 If position is an <literal>integer</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4112 the current file position will remain unchanged. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4113 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4114 </list> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4115 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4116 Returns a <literal>Promise</literal> which fulfills upon success |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4117 with an object with two properties: |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4118 <list type="tag"> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4119 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4120 <tag-name><literal>bytesRead</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4121 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4122 is an <literal>integer</literal> representing the number of bytes read |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4123 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4124 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4125 <tag-name><literal>buffer</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4126 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4127 is a reference to the passed argument in buffer, can be |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4128 <literal>Buffer</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4129 <literal>TypedArray</literal>, or |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4130 <literal>DataView</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4131 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4132 </list> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4133 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4134 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4135 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4136 <tag-name id="filehandle_stat"><literal>filehandle.stat()</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4137 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4138 Fulfills with an |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4139 <link id="fs_stats">fs.Stats</link> for the file, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4140 returns a <literal>promise</literal>. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4141 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4142 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4143 <tag-name id="filehandle_write_buf"><literal>filehandle.write(<value>buffer</value>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4144 <value>offset</value>[, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4145 <value>length</value>[, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4146 <value>position</value>]])</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4147 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4148 Writes a buffer to the file. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4149 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4150 <list type="tag"> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4151 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4152 <tag-name><literal>buffer</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4153 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4154 the <literal>buffer</literal> value can be a |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4155 <literal>Buffer</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4156 <literal>TypedArray</literal>, or |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4157 <literal>DataView</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4158 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4159 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4160 <tag-name><literal>offset</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4161 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4162 is an <literal>integer</literal> representing |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4163 the start position from within buffer where the data to write begins |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4164 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4165 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4166 <tag-name><literal>length</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4167 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4168 is an <literal>integer</literal> representing |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4169 the number of bytes from buffer to write, by default |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4170 is an offset of |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4171 <link id="buffer_bytelength">Buffer.byteLength</link> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4172 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4173 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4174 <tag-name><literal>position</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4175 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4176 the offset from the beginning of the file |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4177 where the data from buffer should be written, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4178 can be an |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4179 <literal>integer</literal> or |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4180 <literal>null</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4181 by default is <literal>null</literal>. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4182 If <literal>position</literal> is not a <literal>number</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4183 the data will be written at the current position. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4184 See the POSIX |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4185 <link url="https://man7.org/linux/man-pages/man2/write.2.html">pwrite(2)</link> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4186 documentation for details. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4187 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4188 </list> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4189 Returns a <literal>Promise</literal> which is resolved with an object |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4190 containing two properties: |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4191 <list type="tag"> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4192 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4193 <tag-name><literal>bytesWritten</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4194 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4195 is an <literal>integer</literal> representing the number of bytes written |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4196 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4197 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4198 <tag-name><literal>buffer</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4199 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4200 a reference to the buffer written, can be a |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4201 <literal>Buffer</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4202 <literal>TypedArray</literal>, or |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4203 <literal>DataView</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4204 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4205 </list> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4206 <para> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4207 <note> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4208 It is unsafe to use <literal>filehandle.write()</literal> multiple times |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4209 on the same file without waiting for the promise to be resolved or rejected. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4210 </note> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4211 </para> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4212 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4213 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4214 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4215 <tag-name id="filehandle_write_str"><literal>filehandle.write(<value>string</value>[, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4216 <value>position</value>[, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4217 <value>encoding</value>]])</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4218 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4219 Writes a <literal>string</literal> to the file. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4220 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4221 <list type="tag"> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4222 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4223 <tag-name><literal>position</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4224 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4225 the offset from the beginning of the file |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4226 where the data from buffer should be written, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4227 can be an |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4228 <literal>integer</literal> or |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4229 <literal>null</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4230 by default is <literal>null</literal>. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4231 If <literal>position</literal> is not a <literal>number</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4232 the data will be written at the current position. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4233 See the POSIX |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4234 <link url="https://man7.org/linux/man-pages/man2/write.2.html">pwrite(2)</link> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4235 documentation for details. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4236 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4237 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4238 <tag-name><literal>encoding</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4239 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4240 the expected encoding of the string, by default <literal>utf8</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4241 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4242 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4243 </list> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4244 Returns a <literal>Promise</literal> which is resolved with an object |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4245 containing two properties: |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4246 <list type="tag"> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4247 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4248 <tag-name><literal>bytesWritten</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4249 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4250 is an <literal>integer</literal> representing the number of bytes written |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4251 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4252 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4253 <tag-name><literal>buffer</literal></tag-name> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4254 <tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4255 a reference to the buffer written, can be a |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4256 <literal>Buffer</literal>, |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4257 <literal>TypedArray</literal>, or |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4258 <literal>DataView</literal> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4259 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4260 </list> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4261 <para> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4262 <note> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4263 It is unsafe to use <literal>filehandle.write()</literal> multiple times |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4264 on the same file without waiting for the promise to be resolved or rejected. |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4265 </note> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4266 </para> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4267 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4268 </tag-desc> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4269 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4270 </list> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4271 </para> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4272 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4273 </section> |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4274 |
155c8745f596
Documented new fs methods and fs.FileHandle in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2884
diff
changeset
|
4275 |
2818
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4276 <section id="fs_stats" name="fs.Stats"> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4277 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4278 <para> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4279 The <literal>fs.Stats</literal> object provides information about a file. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4280 The object is returned from |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4281 <link id="fs_statsync">fs.statSync()</link> and |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4282 <link id="fs_lstatsync">fs.lstatSync()</link>. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4283 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4284 <list type= "bullet" compact="no"> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4285 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4286 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4287 <literal>stats.isBlockDevice()</literal>—returns |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4288 <literal>true</literal> if the <literal>fs.Stats</literal> object describes |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4289 a block device. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4290 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4291 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4292 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4293 <literal>stats.isDirectory()</literal>—returns |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4294 <literal>true</literal> if the <literal>fs.Stats</literal> object describes |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4295 a file system directory. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4296 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4297 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4298 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4299 <literal>stats.isFIFO()</literal>—returns |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4300 <literal>true</literal> if the <literal>fs.Stats</literal> object describes |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4301 a first-in-first-out (FIFO) pipe. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4302 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4303 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4304 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4305 <literal>stats.isFile()</literal>—returns |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4306 <literal>true</literal> if the <literal>fs.Stats</literal> object describes |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4307 a regular file. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4308 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4309 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4310 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4311 <literal>stats.isSocket()</literal>—returns |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4312 <literal>true</literal> if the <literal>fs.Stats</literal> object describes |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4313 a socket. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4314 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4315 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4316 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4317 <literal>stats.isSymbolicLink()</literal>—returns |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4318 <literal>true</literal> if the <literal>fs.Stats</literal> object describes |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4319 a symbolic link. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4320 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4321 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4322 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4323 <literal>stats.dev</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4324 the numeric identifier of the device containing the file. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4325 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4326 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4327 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4328 <literal>stats.ino</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4329 the file system specific <literal>Inode</literal> number for the file. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4330 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4331 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4332 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4333 <literal>stats.mode</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4334 a bit-field describing the file type and mode. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4335 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4336 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4337 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4338 <literal>stats.nlink</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4339 the number of hard-links that exist for the file. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4340 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4341 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4342 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4343 <literal>stats.uid</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4344 the numeric user identifier of the user that owns the file (POSIX). |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4345 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4346 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4347 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4348 <literal>stats.gid</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4349 the numeric group identifier of the group that owns the file (POSIX). |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4350 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4351 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4352 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4353 <literal>stats.rdev</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4354 the numeric device identifier if the file represents a device. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4355 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4356 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4357 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4358 <literal>stats.size</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4359 the size of the file in bytes. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4360 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4361 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4362 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4363 <literal>stats.blksize</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4364 the file system block size for i/o operations. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4365 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4366 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4367 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4368 <literal>stats.blocks</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4369 the number of blocks allocated for this file. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4370 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4371 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4372 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4373 <literal>stats.atimeMs</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4374 the timestamp indicating the last time this file was accessed expressed |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4375 in milliseconds since the POSIX Epoch. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4376 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4377 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4378 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4379 <literal>stats.mtimeMs</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4380 the timestamp indicating the last time this file was modified expressed |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4381 in milliseconds since the POSIX Epoch. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4382 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4383 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4384 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4385 <literal>stats.ctimeMs</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4386 the timestamp indicating the last time this file was changed expressed |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4387 in milliseconds since the POSIX Epoch. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4388 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4389 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4390 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4391 <literal>stats.birthtimeMs</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4392 the timestamp indicating the creation time of this file expressed |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4393 in milliseconds since the POSIX Epoch. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4394 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4395 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4396 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4397 <literal>stats.atime</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4398 the timestamp indicating the last time this file was accessed. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4399 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4400 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4401 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4402 <literal>stats.mtime</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4403 the timestamp indicating the last time this file was modified. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4404 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4405 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4406 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4407 <literal>stats.ctime</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4408 the timestamp indicating the last time this file was changed. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4409 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4410 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4411 <listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4412 <literal>stats.birthtime</literal>— |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4413 the timestamp indicating the creation time of this file. |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4414 </listitem> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4415 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4416 </list> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4417 </para> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4418 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4419 </section> |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4420 |
2594d336342d
Documented fs.Stats, statSync and lstatSync in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2800
diff
changeset
|
4421 |
2507 | 4422 <section id="access_const" name="File Access Constants"> |
4423 | |
4424 <para> | |
4425 The <link id="fs_accesssync"><literal>access()</literal></link> method | |
4426 can accept the following flags. | |
4427 These flags are exported by <literal>fs.constants</literal>: | |
4428 | |
4429 <list type= "bullet" compact="no"> | |
4430 | |
4431 <listitem> | |
4432 <literal>F_OK</literal>—indicates that the file | |
4433 is visible to the calling process, | |
4434 used by default if no mode is specified | |
4435 </listitem> | |
4436 | |
4437 <listitem> | |
4438 <literal>R_OK</literal>—indicates that the file can be | |
4439 read by the calling process | |
4440 </listitem> | |
4441 | |
4442 <listitem> | |
4443 <literal>W_OK</literal>—indicates that the file can be | |
4444 written by the calling process | |
4445 </listitem> | |
4446 | |
4447 <listitem> | |
4448 <literal>X_OK</literal>—indicates that the file can be | |
4449 executed by the calling process | |
4450 </listitem> | |
4451 | |
4452 </list> | |
4453 </para> | |
4454 | |
4455 </section> | |
4456 | |
4457 | |
2204
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4458 <section id="njs_api_fs_flags" name="File System Flags"> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4459 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4460 <para> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4461 The <literal>flag</literal> option can accept the following values: |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4462 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4463 <list type= "bullet" compact="no"> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4464 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4465 <listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4466 <literal>a</literal>—open a file for appending. |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4467 The file is created if it does not exist |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4468 </listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4469 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4470 <listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4471 <literal>ax</literal>—the same as <literal>a</literal> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4472 but fails if the file already exists |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4473 </listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4474 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4475 <listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4476 <literal>a+</literal>—open a file for reading and appending. |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4477 If the file does not exist, it will be created |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4478 </listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4479 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4480 <listitem> |
2579
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
4481 <literal>ax+</literal>—the same as <literal>a+</literal> |
2204
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4482 but fails if the file already exists |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4483 </listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4484 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4485 <listitem> |
2579
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
4486 <literal>as</literal>—open a file for appending |
63cef7604e0d
Minor review of njs Reference for typos and style.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2578
diff
changeset
|
4487 in synchronous mode. |
2204
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4488 If the file does not exist, it will be created |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4489 </listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4490 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4491 <listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4492 <literal>as+</literal>—open a file for reading and appending |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4493 in synchronous mode. |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4494 If the file does not exist, it will be created |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4495 </listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4496 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4497 <listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4498 <literal>r</literal>—open a file for reading. |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4499 An exception occurs if the file does not exist |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4500 </listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4501 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4502 <listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4503 <literal>r+</literal>—open a file for reading and writing. |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4504 An exception occurs if the file does not exist |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4505 </listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4506 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4507 <listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4508 <literal>rs+</literal>—open a file for reading and writing |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4509 in synchronous mode. |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4510 Instructs the operating system to bypass the local file system cache |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4511 </listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4512 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4513 <listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4514 <literal>w</literal>—open a file for writing. |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4515 If the file does not exist, it will be created. |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4516 If the file exists, it will be replaced |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4517 </listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4518 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4519 <listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4520 <literal>wx</literal>—the same as <literal>w</literal> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4521 but fails if the file already exists |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4522 </listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4523 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4524 <listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4525 <literal>w+</literal>—open a file for reading and writing. |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4526 If the file does not exist, it will be created. |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4527 If the file exists, it will be replaced |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4528 </listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4529 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4530 <listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4531 <literal>wx+</literal>—the same as <literal>w+</literal> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4532 but fails if the file already exists |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4533 </listitem> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4534 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4535 </list> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4536 </para> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4537 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4538 </section> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4539 |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4540 </section> |
001f2d905fd9
Documented fileSystem methods in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2203
diff
changeset
|
4541 |
2583
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4542 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4543 <section id="querystring" name="Query String"> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4544 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4545 <para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4546 The Query String module provides support |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4547 for parsing and formatting URL query strings |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4548 (<link doc="changes.xml" id="njs0.4.3">0.4.3</link>). |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4549 The Query String module object is returned by |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4550 <literal>require('querystring')</literal>. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4551 </para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4552 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4553 <para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4554 <list type="tag"> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4555 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4556 <tag-name id="querystring_decode"><literal>querystring.decode()</literal></tag-name> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4557 <tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4558 is an alias for |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4559 <link id="querystring_parse"><literal>querystring.parse()</literal></link>. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4560 </tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4561 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4562 <tag-name id="querystring_encode"><literal>querystring.encode()</literal></tag-name> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4563 <tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4564 is an alias for |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4565 <link id="querystring_stringify"><literal>querystring.stringify()</literal></link>. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4566 </tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4567 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4568 <tag-name id="querystring_escape"><literal>querystring.escape(<value>string</value>)</literal></tag-name> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4569 <tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4570 <para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4571 Performs URL encoding of the given <literal>string</literal>, |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4572 returns an escaped query string. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4573 The method is used by |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4574 <link id="querystring_stringify"><literal>querystring.stringify()</literal></link> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4575 and should not be used directly. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4576 </para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4577 </tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4578 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4579 <tag-name id="querystring_parse"><literal>querystring.parse(<value>string</value>[, |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4580 <value>separator</value>[, |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4581 <value>equal</value>[, |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4582 <value>options</value>]]])</literal></tag-name> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4583 <tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4584 <para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4585 Parses the query string URL and returns an object. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4586 </para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4587 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4588 <para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4589 The <literal>separator</literal> parameter is a substring |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4590 for delimiting key and value pairs in the query string, |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4591 by default is “<literal>&</literal>”. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4592 </para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4593 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4594 <para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4595 The <literal>equal</literal> parameter is a substring |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4596 for delimiting keys and values in the query string, |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4597 by default is “<literal>=</literal>”. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4598 </para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4599 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4600 <para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4601 The <literal>options</literal> parameter is expected to be |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4602 an object with the following keys: |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4603 <list type="tag"> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4604 <tag-name><literal>decodeURIComponent</literal> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4605 <value>function</value></tag-name> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4606 <tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4607 Function used |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4608 to decode percent-encoded characters in the query string, |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4609 by default is |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4610 <link id="querystring_unescape"><literal>querystring.unescape()</literal></link> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4611 </tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4612 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4613 <tag-name><literal>maxKeys</literal> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4614 <value>number</value></tag-name> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4615 <tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4616 the maximum number of keys to parse, |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4617 by default is <literal>1000</literal>. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4618 The <literal>0</literal> value removes limitations for counting keys. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4619 </tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4620 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4621 </list> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4622 By default, percent-encoded characters within the query string are assumed |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4623 to use the UTF-8 encoding, |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4624 invalid UTF-8 sequences will be replaced with |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4625 the <literal>U+FFFD</literal> replacement character. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4626 </para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4627 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4628 <para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4629 For example, for the following query string |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4630 <example> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4631 'foo=bar&abc=xyz&abc=123' |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4632 </example> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4633 the output will be: |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4634 <example> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4635 { |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4636 foo: 'bar', |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4637 abc: ['xyz', '123'] |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4638 } |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4639 </example> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4640 </para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4641 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4642 </tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4643 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4644 <tag-name id="querystring_stringify"><literal>querystring.stringify(<value>object</value>[, |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4645 <value>separator</value>[, |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4646 <value>equal</value>[, |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4647 <value>options</value>]]])</literal></tag-name> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4648 <tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4649 <para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4650 Serializes an object and returns a URL query string. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4651 </para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4652 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4653 <para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4654 The <literal>separator</literal> parameter is a substring |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4655 for delimiting key and value pairs in the query string, |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4656 by default is “<literal>&</literal>”. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4657 </para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4658 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4659 <para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4660 The <literal>equal</literal> parameter is a substring |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4661 for delimiting keys and values in the query string, |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4662 by default is “<literal>=</literal>”. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4663 </para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4664 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4665 <para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4666 The <literal>options</literal> parameter is expected to be |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4667 an object with the following keys: |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4668 <list type="tag"> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4669 <tag-name><literal>encodeURIComponent</literal> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4670 <value>function</value></tag-name> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4671 <tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4672 The function to use when converting |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4673 URL-unsafe characters to percent-encoding in the query string, |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4674 by default is |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4675 <link id="querystring_escape"><literal>querystring.escape()</literal></link>. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4676 </tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4677 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4678 </list> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4679 </para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4680 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4681 <para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4682 By default, characters that require percent-encoding within the query string |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4683 are encoded as UTF-8. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4684 If other encoding is required, then |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4685 <literal>encodeURIComponent</literal> option should be specified. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4686 </para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4687 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4688 <para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4689 For example, for the following command |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4690 <example> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4691 querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], 123: '' }); |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4692 </example> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4693 the query string will be: |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4694 <example> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4695 'foo=bar&baz=qux&baz=quux&123=' |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4696 </example> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4697 </para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4698 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4699 </tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4700 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4701 <tag-name id="querystring_unescape"><literal>querystring.unescape(<value>string</value>)</literal></tag-name> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4702 <tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4703 <para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4704 Performs decoding of URL percent-encoded characters |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4705 of the <literal>string</literal>, |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4706 returns an unescaped query string. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4707 The method is used by |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4708 <link id="querystring_parse"><literal>querystring.parse()</literal></link> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4709 and should not be used directly. |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4710 </para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4711 </tag-desc> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4712 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4713 </list> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4714 </para> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4715 |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4716 </section> |
cd97adddd757
Documented Query String in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2582
diff
changeset
|
4717 |
2176 | 4718 </section> |
4719 | |
2175
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
4720 </article> |