summaryrefslogtreecommitdiff
path: root/sapi/cli
diff options
context:
space:
mode:
Diffstat (limited to 'sapi/cli')
-rw-r--r--sapi/cli/cli.h2
-rw-r--r--sapi/cli/php_cli.c4
-rw-r--r--sapi/cli/php_cli_server.c7
-rw-r--r--sapi/cli/php_cli_server.h2
-rw-r--r--sapi/cli/tests/006.phpt2
-rw-r--r--sapi/cli/tests/bug43177.phpt82
-rw-r--r--sapi/cli/tests/bug61977.phpt164
7 files changed, 123 insertions, 140 deletions
diff --git a/sapi/cli/cli.h b/sapi/cli/cli.h
index 3e9ca4308..7686522a2 100644
--- a/sapi/cli/cli.h
+++ b/sapi/cli/cli.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2012 The PHP Group |
+ | Copyright (c) 1997-2013 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index f9bf3ee60..c01f3705b 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2012 The PHP Group |
+ | Copyright (c) 1997-2013 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -687,7 +687,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
goto out;
case 'v': /* show php version & quit */
- php_printf("PHP %s (%s) (built: %s %s) %s\nCopyright (c) 1997-2012 The PHP Group\n%s",
+ php_printf("PHP %s (%s) (built: %s %s) %s\nCopyright (c) 1997-2013 The PHP Group\n%s",
PHP_VERSION, cli_sapi_module.name, __DATE__, __TIME__,
#if ZEND_DEBUG && defined(HAVE_GCOV)
"(DEBUG GCOV)",
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
index 5f263cb32..28aba198f 100644
--- a/sapi/cli/php_cli_server.c
+++ b/sapi/cli/php_cli_server.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2012 The PHP Group |
+ | Copyright (c) 1997-2013 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -259,10 +259,13 @@ static php_cli_server_ext_mime_type_pair mime_type_map[] = {
{ "gif", "image/gif" },
{ "jpg", "image/jpeg" },
{ "jpeg", "image/jpeg" },
- { "png", "image/png" },
{ "jpe", "image/jpeg" },
+ { "png", "image/png" },
{ "svg", "image/svg+xml" },
{ "txt", "text/plain" },
+ { "webm", "video/webm" },
+ { "ogv", "video/ogg" },
+ { "ogg", "audio/ogg" },
{ NULL, NULL }
};
diff --git a/sapi/cli/php_cli_server.h b/sapi/cli/php_cli_server.h
index 889ebf6f7..ed716f99f 100644
--- a/sapi/cli/php_cli_server.h
+++ b/sapi/cli/php_cli_server.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2012 The PHP Group |
+ | Copyright (c) 1997-2013 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/sapi/cli/tests/006.phpt b/sapi/cli/tests/006.phpt
index 3f3f3c13a..3d5c916e9 100644
--- a/sapi/cli/tests/006.phpt
+++ b/sapi/cli/tests/006.phpt
@@ -69,7 +69,7 @@ string(%d) "Extension [ <persistent> extension #%d pcre version <no_version> ] {
- Parameters [5] {
Parameter #0 [ <required> $pattern ]
Parameter #1 [ <required> $subject ]
- Parameter #2 [ <required> &$subpatterns ]
+ Parameter #2 [ <optional> &$subpatterns ]
Parameter #3 [ <optional> $flags ]
Parameter #4 [ <optional> $offset ]
}
diff --git a/sapi/cli/tests/bug43177.phpt b/sapi/cli/tests/bug43177.phpt
new file mode 100644
index 000000000..36b5504ab
--- /dev/null
+++ b/sapi/cli/tests/bug43177.phpt
@@ -0,0 +1,82 @@
+--TEST--
+Bug #61977 Test exit code for various errors
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+include "php_cli_server.inc";
+php_cli_server_start(<<<'SCRIPT'
+ ini_set('display_errors', 0);
+ switch($_SERVER["REQUEST_URI"]) {
+ case "/parse":
+ eval("this is a parse error");
+ echo "OK\n";
+ break;
+ case "/fatal":
+ eval("foo();");
+ echo "OK\n";
+ break;
+ case "/compile":
+ eval("class foo { final private final function bar() {} }");
+ echo "OK\n";
+ break;
+ case "/fatal2":
+ foo();
+ echo "OK\n";
+ break;
+ default:
+ return false;
+ }
+SCRIPT
+);
+
+list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
+$port = intval($port)?:80;
+
+foreach(array("parse", "fatal", "fatal2", "compile") as $url) {
+ $fp = fsockopen($host, $port, $errno, $errstr, 0.5);
+ if (!$fp) {
+ die("connect failed");
+ }
+
+ if(fwrite($fp, <<<HEADER
+GET /$url HTTP/1.1
+Host: {$host}
+
+
+HEADER
+)) {
+ while (!feof($fp)) {
+ echo fgets($fp);
+ }
+ }
+}
+
+?>
+--EXPECTF--
+HTTP/1.1 200 OK
+Host: localhost
+Connection: close
+X-Powered-By: %s
+Content-type: text/html
+
+OK
+HTTP/1.0 500 Internal Server Error
+Host: localhost
+Connection: close
+X-Powered-By: %s
+Content-type: text/html
+
+HTTP/1.0 500 Internal Server Error
+Host: localhost
+Connection: close
+X-Powered-By: %s
+Content-type: text/html
+
+HTTP/1.0 500 Internal Server Error
+Host: localhost
+Connection: close
+X-Powered-By: %s
+Content-type: text/html
diff --git a/sapi/cli/tests/bug61977.phpt b/sapi/cli/tests/bug61977.phpt
index 2f198060f..09a6ba6d2 100644
--- a/sapi/cli/tests/bug61977.phpt
+++ b/sapi/cli/tests/bug61977.phpt
@@ -1,5 +1,5 @@
--TEST--
-Bug #61977 (Need CLI web-server support for files with .htm & svg extensions)
+Bug #61977 test CLI web-server support for Mime Type File extensions mapping
--SKIPIF--
<?php
include "skipif.inc";
@@ -8,145 +8,40 @@ include "skipif.inc";
<?php
include "php_cli_server.inc";
php_cli_server_start('<?php ?>', 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, <<<HEADER
-GET /foo.html HTTP/1.1
-Host: {$host}
-
-
-HEADER
-)) {
- while (!feof($fp)) {
- $text = fgets($fp);
- if (strncasecmp("Content-type:", $text, 13) == 0) {
- echo "foo.html => ", $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, <<<HEADER
-GET /foo.htm HTTP/1.1
-Host: {$host}
-
-
-HEADER
-)) {
- while (!feof($fp)) {
- $text = fgets($fp);
- if (strncasecmp("Content-type:", $text, 13) == 0) {
- echo "foo.htm => ", $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, <<<HEADER
-GET /foo.svg HTTP/1.1
+/*
+ * If a Mime Type is added in php_cli_server.c, add it to this array and update
+ * the EXPECTF section accordingly
+ */
+$mimetypes = ['html', 'htm', 'svg', 'css', 'js', 'png', 'webm', 'ogv', 'ogg'];
+
+function test_mimetypes($mimetypes) {
+ foreach ($mimetypes as $mimetype) {
+ 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(__DIR__ . "/foo.{$mimetype}", '');
+ $header = <<<HEADER
+GET /foo.{$mimetype} HTTP/1.1
Host: {$host}
-HEADER
-)) {
- while (!feof($fp)) {
- $text = fgets($fp);
- if (strncasecmp("Content-type:", $text, 13) == 0) {
- echo "foo.svg => ", $text;
+HEADER;
+ 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.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, <<<HEADER
-GET /foo.css HTTP/1.1
-Host: {$host}
-
-
-HEADER
-)) {
- while (!feof($fp)) {
- $text = fgets($fp);
- if (strncasecmp("Content-type:", $text, 13) == 0) {
- echo "foo.css => ", $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, <<<HEADER
-GET /foo.js HTTP/1.1
-Host: {$host}
-
-
-HEADER
-)) {
- while (!feof($fp)) {
- $text = fgets($fp);
- if (strncasecmp("Content-type:", $text, 13) == 0) {
- echo "foo.js => ", $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, <<<HEADER
-GET /foo.png HTTP/1.1
-Host: {$host}
-
-
-HEADER
-)) {
- while (!feof($fp)) {
- $text = fgets($fp);
- if (strncasecmp("Content-type:", $text, 13) == 0) {
- echo "foo.png => ", $text;
- }
- }
-}
-@unlink($doc_root . '/foo.png');
-fclose($fp);
+test_mimetypes($mimetypes);
?>
--EXPECTF--
foo.html => Content-Type: text/html; charset=UTF-8
@@ -155,3 +50,6 @@ 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
+foo.webm => Content-Type: video/webm
+foo.ogv => Content-Type: video/ogg
+foo.ogg => Content-Type: audio/ogg