From 1e60d0c105f065f395b5ae02608eaec9b42708f8 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Wed, 9 May 2012 11:27:39 +0800 Subject: [PATCH] Implemented FR #61977 (Need CLI web-server support for files with .htm & svg extensions) --- NEWS | 2 + sapi/cli/php_cli_server.c | 12 +-- sapi/cli/tests/bug61977.phpt | 157 +++++++++++++++++++++++++++++++++++ 3 files changed, 166 insertions(+), 5 deletions(-) create mode 100644 sapi/cli/tests/bug61977.phpt diff --git a/NEWS b/NEWS index d989f34db7a..cb00f7a2734 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ PHP NEWS ?? ??? 2012, PHP 5.4.2 - CLI Server: + . Implemented FR #61977 (Need CLI web-server support for files with .htm & + svg extensions). (Sixd, Laruence) . Fixed bug #61546 (functions related to current script failed when chdir() in cli sapi). (Laruence, reeze.xia@gmail.com) . Improved performance while sending error page, this also fixed diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index e052aa8dd6b..87ab7b48f49 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -251,15 +251,17 @@ static php_cli_server_http_reponse_status_code_pair template_map[] = { }; static php_cli_server_ext_mime_type_pair mime_type_map[] = { + { "html", "text/html" }, + { "htm", "text/html" }, + { "js", "text/javascript" }, + { "css", "text/css" }, { "gif", "image/gif" }, - { "png", "image/png" }, - { "jpe", "image/jpeg" }, { "jpg", "image/jpeg" }, { "jpeg", "image/jpeg" }, - { "css", "text/css" }, - { "html", "text/html" }, + { "png", "image/png" }, + { "jpe", "image/jpeg" }, + { "svg", "image/svg+xml" }, { "txt", "text/plain" }, - { "js", "text/javascript" }, { NULL, NULL } }; diff --git a/sapi/cli/tests/bug61977.phpt b/sapi/cli/tests/bug61977.phpt new file mode 100644 index 00000000000..edb7b78d7fb --- /dev/null +++ b/sapi/cli/tests/bug61977.phpt @@ -0,0 +1,157 @@ +--TEST-- +Bug #60159 (Router returns false, but POST is not passed to requested resource) +--SKIPIF-- + +--FILE-- +', true); +$doc_root = __DIR__; + +list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); +$port = intval($port)?:80; + +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} + +file_put_contents($doc_root . '/foo.html', ''); +if(fwrite($fp, <<
", $text; + } + } +} +@unlink($doc_root . '/foo.html'); +fclose($fp); + + +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} +file_put_contents($doc_root . '/foo.htm', ''); +if(fwrite($fp, <<
", $text; + } + } +} +@unlink($doc_root . '/foo.htm'); +fclose($fp); + + +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} +file_put_contents($doc_root . '/foo.svg', ''); +if(fwrite($fp, <<
", $text; + } + } +} +@unlink($doc_root . '/foo.svg'); +fclose($fp); + +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} +file_put_contents($doc_root . '/foo.css', ''); +if(fwrite($fp, <<
", $text; + } + } +} +@unlink($doc_root . '/foo.css'); +fclose($fp); + +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} +file_put_contents($doc_root . '/foo.js', ''); +if(fwrite($fp, <<
", $text; + } + } +} +@unlink($doc_root . '/foo.js'); +fclose($fp); + +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} +file_put_contents($doc_root . '/foo.png', ''); +if(fwrite($fp, <<
", $text; + } + } +} +@unlink($doc_root . '/foo.png'); +fclose($fp); +?> +--EXPECTF-- +foo.html => Content-Type: text/html; charset=UTF-8 +foo.htm => Content-Type: text/html; charset=UTF-8 +foo.svg => Content-Type: image/svg+xml +foo.css => Content-Type: text/css; charset=UTF-8 +foo.js => Content-Type: text/javascript; charset=UTF-8 +foo.png => Content-Type: image/png