xref: /PHP-5.5/ext/standard/tests/http/bug61548.phpt (revision 18b04b48)
1--TEST--
2Bug #61548 (content-type must appear at the end of headers)
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($header) {
12    $options = [
13        'http' => [
14			'method' => 'POST',
15			'header' => $header,
16            'follow_location' => true,
17        ],
18    ];
19
20    $ctx = stream_context_create($options);
21
22    $responses = [
23		"data://text/plain,HTTP/1.1 201\r\nLocation: /foo\r\n\r\n",
24		"data://text/plain,HTTP/1.1 200\r\nConnection: close\r\n\r\n",
25	];
26    $pid = http_server('tcp://127.0.0.1:12342', $responses, $output);
27
28    $fd = fopen('http://127.0.0.1:12342/', 'rb', false, $ctx);
29    fseek($output, 0, SEEK_SET);
30    echo stream_get_contents($output);
31
32    http_server_kill($pid);
33}
34
35do_test("First:1\nSecond:2\nContent-type: text/plain");
36do_test("First:1\nSecond:2\nContent-type: text/plain\n");
37do_test("First:1\nSecond:2\nContent-type: text/plain\nThird:");
38do_test("First:1\nContent-type:text/plain\nSecond:2");
39do_test("First:1\nContent-type:text/plain\nSecond:2\n");
40do_test("First:1\nContent-type:text/plain\nSecond:2\nThird:");
41
42?>
43Done
44--EXPECT--
45POST / HTTP/1.0
46Host: 127.0.0.1:12342
47First:1
48Second:2
49Content-type: text/plain
50
51GET /foo HTTP/1.0
52Host: 127.0.0.1:12342
53First:1
54Second:2
55
56
57POST / HTTP/1.0
58Host: 127.0.0.1:12342
59First:1
60Second:2
61Content-type: text/plain
62
63GET /foo HTTP/1.0
64Host: 127.0.0.1:12342
65First:1
66Second:2
67
68
69POST / HTTP/1.0
70Host: 127.0.0.1:12342
71First:1
72Second:2
73Content-type: text/plain
74Third:
75
76GET /foo HTTP/1.0
77Host: 127.0.0.1:12342
78First:1
79Second:2
80Third:
81
82POST / HTTP/1.0
83Host: 127.0.0.1:12342
84First:1
85Content-type:text/plain
86Second:2
87
88GET /foo HTTP/1.0
89Host: 127.0.0.1:12342
90First:1
91Second:2
92
93POST / HTTP/1.0
94Host: 127.0.0.1:12342
95First:1
96Content-type:text/plain
97Second:2
98
99GET /foo HTTP/1.0
100Host: 127.0.0.1:12342
101First:1
102Second:2
103
104POST / HTTP/1.0
105Host: 127.0.0.1:12342
106First:1
107Content-type:text/plain
108Second:2
109Third:
110
111GET /foo HTTP/1.0
112Host: 127.0.0.1:12342
113First:1
114Second:2
115Third:
116
117Done
118
119