/
bug67430.phpt
52 lines (42 loc) · 1005 Bytes
/
bug67430.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
--TEST--
Bug #67430 (http:// wrapper doesn't follow 308 redirects)
--INI--
allow_url_fopen=1
--SKIPIF--
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
--FILE--
<?php
require 'server.inc';
function do_test($follow) {
$options = [
'http' => [
'method' => 'POST',
'follow_location' => $follow,
],
];
$ctx = stream_context_create($options);
$responses = [
"data://text/plain,HTTP/1.1 308\r\nLocation: /foo\r\n\r\n",
"data://text/plain,HTTP/1.1 200\r\nConnection: close\r\n\r\n",
];
$pid = http_server('tcp://127.0.0.1:12342', $responses, $output);
$fd = fopen('http://127.0.0.1:12342/', 'rb', false, $ctx);
fseek($output, 0, SEEK_SET);
echo stream_get_contents($output);
http_server_kill($pid);
}
do_test(true);
do_test(false);
?>
Done
--EXPECT--
POST / HTTP/1.0
Host: 127.0.0.1:12342
Connection: close
GET /foo HTTP/1.0
Host: 127.0.0.1:12342
Connection: close
POST / HTTP/1.0
Host: 127.0.0.1:12342
Connection: close
Done