Skip to content

Commit 5bebadb

Browse files
CLI server: add regression tests for "Host" header reflection
The server responds with a "Host" header that is copied from the request, add a test so that when the behavior changes it is visible.
1 parent 5d24c8b commit 5bebadb

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
--TEST--
2+
Built-in web server reflects arbitrary `Host` headers
3+
--SKIPIF--
4+
<?php
5+
include "skipif.inc";
6+
?>
7+
--FILE--
8+
<?php
9+
include "php_cli_server.inc";
10+
php_cli_server_start(<<<'PHP'
11+
echo "Request headers:\n";
12+
var_dump(getallheaders());
13+
PHP
14+
);
15+
16+
$req = <<<END
17+
GET / HTTP/1.1
18+
Host: Foo Bar Baz
19+
20+
21+
22+
END;
23+
24+
$fp = php_cli_server_connect();
25+
if (fwrite($fp, $req)) {
26+
while (!feof($fp)) {
27+
echo fgets($fp);
28+
}
29+
}
30+
fclose($fp);
31+
32+
?>
33+
--EXPECTF--
34+
HTTP/1.1 200 OK
35+
Host: Foo Bar Baz
36+
Date: %s
37+
Connection: close
38+
X-Powered-By: %s
39+
Content-type: text/html; charset=UTF-8
40+
41+
Request headers:
42+
array(1) {
43+
["Host"]=>
44+
string(11) "Foo Bar Baz"
45+
}

0 commit comments

Comments
 (0)