php-src/sapi/cli/tests/php_cli_server_016.phpt
Ilija Tovilo d7d0d19d32
Support index.php fallback for files in built-in server
If no router script is used, the built-in webserver will now look for a fallback
index file recursively in all cases, including URLs with a period.

Fixes GH-12604
Closes GH-12992
2024-01-09 16:13:39 +01:00

43 lines
854 B
PHP

--TEST--
Bug #60591 (Memory leak when access a non-exists file)
--DESCRIPTION--
this is an indirect test for bug 60591, since mem leak is reproted in the server side
and require php compiled with --enable-debug
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
include "php_cli_server.inc";
$info = php_cli_server_start(null, 'router.php');
file_put_contents($info->docRoot . '/router.php', <<<'PHP'
<?php
if (preg_match('/\.(?:png|jpg|jpeg|gif)$/', $_SERVER["REQUEST_URI"]))
return false; // serve the requested resource as-is.
else {
echo "here";
}
PHP
);
$host = PHP_CLI_SERVER_HOSTNAME;
$fp = php_cli_server_connect();
if(fwrite($fp, <<<HEADER
POST /no-exists.jpg HTTP/1.1
Host: {$host}
HEADER
)) {
while (!feof($fp)) {
echo fgets($fp);
break;
}
}
fclose($fp);
?>
--EXPECT--
HTTP/1.1 404 Not Found