diff options
Diffstat (limited to 'sapi/cli/tests/bug61977.phpt')
-rw-r--r-- | sapi/cli/tests/bug61977.phpt | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/sapi/cli/tests/bug61977.phpt b/sapi/cli/tests/bug61977.phpt index b55c6a2e8f..e804e0dfce 100644 --- a/sapi/cli/tests/bug61977.phpt +++ b/sapi/cli/tests/bug61977.phpt @@ -7,7 +7,7 @@ include "skipif.inc"; --FILE-- <?php include "php_cli_server.inc"; -php_cli_server_start('<?php ?>', null); +$doc_root = php_cli_server_start('<?php ?>', null)->docRoot; /* * If a Mime Type is added in php_cli_server.c, add it to this array and update @@ -15,32 +15,29 @@ php_cli_server_start('<?php ?>', null); */ $mimetypes = ['html', 'htm', 'svg', 'css', 'js', 'png', 'webm', 'ogv', 'ogg']; -function test_mimetypes($mimetypes) { - foreach ($mimetypes as $mimetype) { - $host = PHP_CLI_SERVER_HOSTNAME; - $fp = php_cli_server_connect(); - if (!$fp) die('Connect failed'); - file_put_contents(__DIR__ . "/foo.{$mimetype}", ''); - $header = <<<HEADER +foreach ($mimetypes as $mimetype) { + $host = PHP_CLI_SERVER_HOSTNAME; + $fp = php_cli_server_connect(); + if (!$fp) die('Connect failed'); + file_put_contents($doc_root . "/foo.{$mimetype}", ''); + $header = <<<HEADER GET /foo.{$mimetype} HTTP/1.1 Host: {$host} HEADER; - if (fwrite($fp, $header)) { - while (!feof($fp)) { - $text = fgets($fp); - if (strncasecmp("Content-type:", $text, 13) == 0) { - echo "foo.{$mimetype} => ", $text; - } + if (fwrite($fp, $header)) { + while (!feof($fp)) { + $text = fgets($fp); + if (strncasecmp("Content-type:", $text, 13) == 0) { + echo "foo.{$mimetype} => ", $text; } - @unlink(__DIR__ . "/foo.{$mimetype}"); - fclose($fp); } + @unlink($doc_root . "/foo.{$mimetype}"); + fclose($fp); } } -test_mimetypes($mimetypes); ?> --EXPECT-- foo.html => Content-Type: text/html; charset=UTF-8 |