language/context/http.xml
3abd17e61d5022d503604cc06894254e3281acf5
...
...
@@ -1,7 +1,7 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
3

4
-
<refentry xml:id="context.http" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" role="noversion">
4
+
<refentry xml:id="context.http" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="verify_info:false" role="stream_context_option">
5
5
<refnamediv>
6
6
<refname>HTTP context options</refname>
7
7
<refpurpose>HTTP context option listing</refpurpose>
...
...
@@ -37,14 +37,24 @@
37
37
<varlistentry xml:id="context.http.header">
38
38
<term>
39
39
<parameter>header</parameter>
40
-
<type>string</type>
40
+
<type>array</type> or <type>string</type>
41
41
</term>
42
42
<listitem>
43
43
<para>
44
44
Additional headers to be sent during request. Values
45
45
in this option will override other values (such as
46
46
<literal>User-agent:</literal>, <literal>Host:</literal>,
47
-
and <literal>Authentication:</literal>).
47
+
and <literal>Authentication:</literal>),
48
+
even when following <literal>Location:</literal> redirects.
49
+
Thus it is not recommended to set a <literal>Host:</literal> header,
50
+
if <parameter>follow_location</parameter> is enabled.
51
+
</para>
52
+
<para>
53
+
String value should be <literal>Key: value</literal> pairs delimited by
54
+
<literal>\r\n</literal>, e.g.
55
+
<literal>"Content-Type: application/json\r\nConnection: close"</literal>.
56
+
Array value should be a list of <literal>Key: value</literal> pairs, e.g.
57
+
<literal>["Content-Type: application/json", "Connection: close"]</literal>.
48
58
</para>
49
59
</listitem>
50
60
</varlistentry>
...
...
@@ -85,7 +95,7 @@
85
95
</term>
86
96
<listitem>
87
97
<para>
88
-
URI specifying address of proxy server. (e.g.
98
+
URI specifying address of proxy server (e.g.
89
99
<literal>tcp://proxy.example.com:5100</literal>).
90
100
</para>
91
101
</listitem>
...
...
@@ -93,12 +103,12 @@
93
103
<varlistentry xml:id="context.http.request-fulluri">
94
104
<term>
95
105
<parameter>request_fulluri</parameter>
96
-
<type>boolean</type>
106
+
<type>bool</type>
97
107
</term>
98
108
<listitem>
99
109
<para>
100
110
When set to &true;, the entire URI will be used when
101
-
constructing the request. (i.e.
111
+
constructing the request (e.g.
102
112
<literal>GET http://www.example.com/path/to/file.html HTTP/1.0</literal>).
103
113
While this is a non-standard request format, some
104
114
proxy servers require it.
...
...
@@ -111,7 +121,7 @@
111
121
<varlistentry xml:id="context.http.follow-location">
112
122
<term>
113
123
<parameter>follow_location</parameter>
114
-
<type>integer</type>
124
+
<type>int</type>
115
125
</term>
116
126
<listitem>
117
127
<para>
...
...
@@ -126,7 +136,7 @@
126
136
<varlistentry xml:id="context.http.max-redirects">
127
137
<term>
128
138
<parameter>max_redirects</parameter>
129
-
<type>integer</type>
139
+
<type>int</type>
130
140
</term>
131
141
<listitem>
132
142
<para>
...
...
@@ -148,15 +158,9 @@
148
158
HTTP protocol version.
149
159
</para>
150
160
<para>
151
-
Defaults to <literal>1.0</literal>.
161
+
Defaults to <literal>1.1</literal> as of PHP 8.0.0;
162
+
prior to that version the default was <literal>1.0</literal>.
152
163
</para>
153
-
<note>
154
-
<para>
155
-
PHP prior to 5.3.0 does not implement chunked transfer decoding.
156
-
If this value is set to <literal>1.1</literal> it is your
157
-
responsibility to be <literal>1.1</literal> compliant.
158
-
</para>
159
-
</note>
160
164
</listitem>
161
165
</varlistentry>
162
166
<varlistentry xml:id="context.http.timeout">
...
...
@@ -179,7 +183,7 @@
179
183
<varlistentry xml:id="context.http.ignore-errors">
180
184
<term>
181
185
<parameter>ignore_errors</parameter>
182
-
<type>boolean</type>
186
+
<type>bool</type>
183
187
</term>
184
188
<listitem>
185
189
<para>
...
...
@@ -194,73 +198,6 @@
194
198
</para>
195
199
</refsect1><!-- }}} -->
196
200

197
-
<refsect1 role="changelog"><!-- {{{ -->
198
-
&reftitle.changelog;
199
-
<para>
200
-
<informaltable>
201
-
<tgroup cols="2">
202
-
<thead>
203
-
<row>
204
-
<entry>&Version;</entry>
205
-
<entry>&Description;</entry>
206
-
</row>
207
-
</thead>
208
-
<tbody>
209
-
<row>
210
-
<entry>5.3.4</entry>
211
-
<entry>
212
-
Added <parameter>follow_location</parameter>.
213
-
</entry>
214
-
</row>
215
-
<row>
216
-
<entry>5.3.0</entry>
217
-
<entry>
218
-
The <parameter>protocol_version</parameter> supports chunked transfer
219
-
decoding when set to <literal>1.1</literal>.
220
-
</entry>
221
-
</row>
222
-
<row>
223
-
<entry>5.2.10</entry>
224
-
<entry>
225
-
Added <parameter>ignore_errors</parameter>.
226
-
</entry>
227
-
</row>
228
-
<row>
229
-
<entry>5.2.10</entry>
230
-
<entry>
231
-
The <parameter>header</parameter> can now be an numerically indexed <type>array</type>.
232
-
</entry>
233
-
</row>
234
-
<row>
235
-
<entry>5.2.1</entry>
236
-
<entry>
237
-
Added <parameter>timeout</parameter>.
238
-
</entry>
239
-
</row>
240
-
<row>
241
-
<entry>5.1.0</entry>
242
-
<entry>
243
-
Added HTTPS proxying through HTTP proxies.
244
-
</entry>
245
-
</row>
246
-
<row>
247
-
<entry>5.1.0</entry>
248
-
<entry>
249
-
Added <parameter>max_redirects</parameter>.
250
-
</entry>
251
-
</row>
252
-
<row>
253
-
<entry>5.1.0</entry>
254
-
<entry>
255
-
Added <parameter>protocol_version</parameter>.
256
-
</entry>
257
-
</row>
258
-
</tbody>
259
-
</tgroup>
260
-
</informaltable>
261
-
</para>
262
-
</refsect1><!-- }}} -->
263
-
264
201
<refsect1 role="examples"><!-- {{{ -->
265
202
&reftitle.examples;
266
203
<para>
...
...
@@ -271,19 +208,19 @@
271
208
<?php
272
209

273
210
$postdata = http_build_query(
274
-
array(
211
+
[
275
212
'var1' => 'some content',
276
-
'var2' => 'doh'
277
-
)
213
+
'var2' => 'doh',
214
+
]
278
215
);
279
216

280
-
$opts = array('http' =>
281
-
array(
217
+
$opts = [
218
+
'http' => [
282
219
'method' => 'POST',
283
220
'header' => 'Content-type: application/x-www-form-urlencoded',
284
-
'content' => $postdata
285
-
)
286
-
);
221
+
'content' => $postdata,
222
+
]
223
+
];
287
224

288
225
$context = stream_context_create($opts);
289
226

...
...
@@ -296,20 +233,20 @@ $result = file_get_contents('http://example.com/submit.php', false, $context);
296
233
</para>
297
234
<para>
298
235
<example xml:id="context.http.example-fetch-ignore-redirect"><!-- {{{ -->
299
-
<title>Ignore redirects but fetch headers and content </title>
236
+
<title>Ignore redirects but fetch headers and content</title>
300
237
<programlisting role="php">
301
238
<![CDATA[
302
239
<?php
303
240

304
241
$url = "http://www.example.org/header.php";
305
242

306
-
$opts = array('http' =>
307
-
array(
308
-
'method' => 'GET',
243
+
$opts = [
244
+
'http' => [
245
+
'method' => 'GET',
309
246
'max_redirects' => '0',
310
-
'ignore_errors' => '1'
311
-
)
312
-
);
247
+
'ignore_errors' => '1',
248
+
]
249
+
];
313
250

314
251
$context = stream_context_create($opts);
315
252
$stream = fopen($url, 'r', false, $context);
...
...
@@ -355,7 +292,7 @@ fclose($stream);
355
292
array (
356
293
'wrapper_data' =>
357
294
array (
358
-
0 => 'HTTP/1.0 301 Moved Permantenly',
295
+
0 => 'HTTP/1.0 301 Moved Permanently',
359
296
1 => 'Cache-Control: no-cache',
360
297
2 => 'Connection: close',
361
298
3 => 'Location: http://example.com/foo.jpg',
362
299