Mercurial > hg > nginx-site
comparison xml/en/docs/njs/reference.xml @ 2988:8899986c3622
Documented Headers, Request, Response constructors in njs Reference.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Thu, 06 Jul 2023 12:30:11 +0100 |
parents | b70e9b806810 |
children | 703d3450cd81 |
comparison
equal
deleted
inserted
replaced
2987:b70e9b806810 | 2988:8899986c3622 |
---|---|
7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> | 7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> |
8 | 8 |
9 <article name="Reference" | 9 <article name="Reference" |
10 link="/en/docs/njs/reference.html" | 10 link="/en/docs/njs/reference.html" |
11 lang="en" | 11 lang="en" |
12 rev="109"> | 12 rev="110"> |
13 | 13 |
14 <section id="summary"> | 14 <section id="summary"> |
15 | 15 |
16 <para> | 16 <para> |
17 <link doc="index.xml">njs</link> provides objects, methods and properties | 17 <link doc="index.xml">njs</link> provides objects, methods and properties |
920 <link id="ngx_fetch"><literal>Fetch API</literal></link> | 920 <link id="ngx_fetch"><literal>Fetch API</literal></link> |
921 is available since <link doc="changes.xml" id="njs0.5.1">0.5.1</link>. | 921 is available since <link doc="changes.xml" id="njs0.5.1">0.5.1</link>. |
922 </para> | 922 </para> |
923 | 923 |
924 <para> | 924 <para> |
925 A new <literal>Headers</literal> object can be created using | 925 A new <literal>Headers</literal> object can be created using the |
926 the <literal>Headers()</literal> constructor | 926 <link id="headers_constructor"><literal>Headers()</literal></link> constructor: |
927 (since <link doc="changes.xml" id="njs0.7.10">0.7.10</link>) | 927 (since <link doc="changes.xml" id="njs0.7.10">0.7.10</link>): |
928 | |
929 <list type="tag"> | |
930 | |
931 <tag-name id="headers_constructor"><literal>Headers([<value>init</value>])</literal></tag-name> | |
932 <tag-desc> | |
933 | |
934 <list type="tag"> | |
935 | |
936 <tag-name><literal>init</literal></tag-name> | |
937 <tag-desc> | |
938 An object containing HTTP headers for | |
939 prepopulating the <literal>Headers</literal> object, | |
940 can be a <literal>string</literal>, | |
941 an <literal>array</literal> of name-value pairs, | |
942 or an existing <literal>Headers</literal> object. | |
943 </tag-desc> | |
944 | |
945 </list> | |
946 </tag-desc> | |
947 | |
948 </list> | |
949 </para> | |
950 | |
951 <para> | |
952 A new <literal>Headers</literal> object can be created | |
928 with the following properties and methods: | 953 with the following properties and methods: |
929 | 954 |
930 <list type="tag"> | 955 <list type="tag"> |
931 | 956 |
932 <tag-name id="headers_append"><literal>append()</literal></tag-name> | 957 <tag-name id="headers_append"><literal>append()</literal></tag-name> |
988 <link id="ngx_fetch"><literal>Fetch API</literal></link> | 1013 <link id="ngx_fetch"><literal>Fetch API</literal></link> |
989 is available since <link doc="changes.xml" id="njs0.7.10">0.7.10</link>. | 1014 is available since <link doc="changes.xml" id="njs0.7.10">0.7.10</link>. |
990 </para> | 1015 </para> |
991 | 1016 |
992 <para> | 1017 <para> |
993 A new <literal>Request</literal> object can be created using | 1018 A new <literal>Request</literal> object can be created using the |
994 the <literal>Request()</literal> constructor | 1019 <link id="request_constructor"><literal>Request()</literal></link> constructor: |
1020 | |
1021 <list type="tag"> | |
1022 | |
1023 <tag-name id="request_constructor"><literal>Request[<value>resource</value>[, | |
1024 <value>options</value>]])</literal></tag-name> | |
1025 <tag-desc> | |
1026 | |
1027 Creates a <literal>Request</literal> object to fetch | |
1028 that can be passed later to | |
1029 <link id="ngx_fetch"><literal>ngx.fetch()</literal></link>. | |
1030 The <literal>resource</literal> can be a URL | |
1031 or an existing <literal>Request</literal> object. | |
1032 The <literal>options</literal> is an optional argument | |
1033 that is expected to be an object with the following keys: | |
1034 | |
1035 <list type="tag"> | |
1036 | |
1037 <tag-name><literal>body</literal></tag-name> | |
1038 <tag-desc> | |
1039 The request body, by default is empty. | |
1040 </tag-desc> | |
1041 | |
1042 <tag-name><literal>headers</literal></tag-name> | |
1043 <tag-desc> | |
1044 The response headers object— | |
1045 the object containing HTTP headers for | |
1046 prepopulating the <link id="headers"><literal>Headers</literal></link> object, | |
1047 can be a <literal>string</literal>, | |
1048 an <literal>array</literal> of name-value pairs, | |
1049 or an existing <link id="headers"><literal>Headers</literal></link> object. | |
1050 </tag-desc> | |
1051 | |
1052 <tag-name><literal>method</literal></tag-name> | |
1053 <tag-desc> | |
1054 The HTTP method, by default the GET method is used. | |
1055 </tag-desc> | |
1056 | |
1057 </list> | |
1058 </tag-desc> | |
1059 | |
1060 </list> | |
1061 </para> | |
1062 | |
1063 <para> | |
1064 A new <literal>Request</literal> object can be created | |
995 with the following properties and methods: | 1065 with the following properties and methods: |
996 | 1066 |
997 <list type="tag"> | 1067 <list type="tag"> |
998 | 1068 |
999 <tag-name id="request_arraybuffer"><literal>arrayBuffer()</literal></tag-name> | 1069 <tag-name id="request_arraybuffer"><literal>arrayBuffer()</literal></tag-name> |
1065 The <literal>Response</literal> interface is available since | 1135 The <literal>Response</literal> interface is available since |
1066 <link doc="changes.xml" id="njs0.5.1">0.5.1</link>. | 1136 <link doc="changes.xml" id="njs0.5.1">0.5.1</link>. |
1067 </para> | 1137 </para> |
1068 | 1138 |
1069 <para> | 1139 <para> |
1070 A new <literal>Response</literal> object can be created using | 1140 A new <literal>Response</literal> object can be created using the |
1071 the <literal>Response()</literal> constructor | 1141 <link id="response_constructor"><literal>Response()</literal></link> constructor |
1072 (since <link doc="changes.xml" id="njs0.7.10">0.7.10</link>) | 1142 (since <link doc="changes.xml" id="njs0.7.10">0.7.10</link>): |
1143 | |
1144 <list type="tag"> | |
1145 | |
1146 <tag-name id="response_constructor"><literal>Response[<value>body</value>[, | |
1147 <value>options</value>]])</literal></tag-name> | |
1148 <tag-desc> | |
1149 Creates a <literal>Response</literal> object. | |
1150 The <literal>body</literal> is an optional argument, | |
1151 can be a <literal>string</literal> or a <literal>buffer</literal>, | |
1152 by default is <literal>null</literal>. | |
1153 The <literal>options</literal> is an optional argument | |
1154 that is expected to be an object with the following keys: | |
1155 | |
1156 <list type="tag"> | |
1157 | |
1158 <tag-name><literal>headers</literal></tag-name> | |
1159 <tag-desc> | |
1160 The response headers object— | |
1161 the object containing HTTP headers for | |
1162 prepopulating the <link id="headers"><literal>Headers</literal></link> object, | |
1163 can be a <literal>string</literal>, | |
1164 an <literal>array</literal> of name-value pairs, | |
1165 or an existing <link id="headers"><literal>Headers</literal></link> object. | |
1166 </tag-desc> | |
1167 | |
1168 <tag-name><literal>status</literal></tag-name> | |
1169 <tag-desc> | |
1170 The status code of the response. | |
1171 </tag-desc> | |
1172 | |
1173 <tag-name><literal>statusText</literal></tag-name> | |
1174 <tag-desc> | |
1175 The status message corresponding to the status code. | |
1176 </tag-desc> | |
1177 | |
1178 </list> | |
1179 </tag-desc> | |
1180 | |
1181 </list> | |
1182 </para> | |
1183 | |
1184 <para> | |
1185 A new <literal>Response()</literal> object can be created | |
1073 with the following properties and methods: | 1186 with the following properties and methods: |
1074 | 1187 |
1075 <list type="tag"> | 1188 <list type="tag"> |
1076 | 1189 |
1077 <tag-name id="response_arraybuffer"><literal>arrayBuffer()</literal></tag-name> | 1190 <tag-name id="response_arraybuffer"><literal>arrayBuffer()</literal></tag-name> |