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