com php-src: add NEWS entry; add simple test: NEWS sapi/cli/tes ts/php_cli_server.inc sapi/cli/tests/upload_2G.ph pt
| From: | Michael Wallner | Date: | Tue, 06 Aug 2013 20:51:58 +0000 |
| Subject: | com php-src: add NEWS entry; add simple test: NEWS sapi/cli/tes ts/php_cli_server.inc sapi/cli/tests/upload_2G.ph pt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-72870@lists.php.net to get a copy of this message | ||
Commit: 4a9d7c1f001a558ab0ebddb74e3b81d8d58b8095
Author: Michael Wallner <mike@php.net> Mon, 5 Aug 2013 13:53:35 +0200
Parents: 8a7ea474a4f8d8e61e0ed9d82cf764eb6b13f580
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4a9d7c1f001a558ab0ebddb74e3b81d8d58b8095
Log:
add NEWS entry; add simple test
Changed paths:
M NEWS
M sapi/cli/tests/php_cli_server.inc
A sapi/cli/tests/upload_2G.phpt
Diff:
diff --git a/NEWS b/NEWS
index c679b90..3ef4a97 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ PHP NEWS
. Improved IS_VAR operands fetching. (Laruence, Dmitry)
. Implemented internal operator overloading
(RFC: https://wiki.php.net/rfc/operator_overloading_gmp).
(Nikita)
+ . Enabled file uploads greater than 2G (Ralf Lang, Mike)
- mysqlnd:
. Disabled flag for SP OUT variables for 5.5+ servers as they are not natively
diff --git a/sapi/cli/tests/php_cli_server.inc b/sapi/cli/tests/php_cli_server.inc
index 40c5361..77a79e0 100644
--- a/sapi/cli/tests/php_cli_server.inc
+++ b/sapi/cli/tests/php_cli_server.inc
@@ -3,7 +3,7 @@ define ("PHP_CLI_SERVER_HOSTNAME", "localhost");
define ("PHP_CLI_SERVER_PORT", 8964);
define ("PHP_CLI_SERVER_ADDRESS",
PHP_CLI_SERVER_HOSTNAME.":".PHP_CLI_SERVER_PORT);
-function php_cli_server_start($code = 'echo "Hello world";', $no_router =
FALSE) {
+function php_cli_server_start($code = 'echo "Hello world";', $no_router =
FALSE, $cmd_args = null) {
$php_executable = getenv('TEST_PHP_EXECUTABLE');
$doc_root = __DIR__;
$router = "index.php";
@@ -19,14 +19,14 @@ function php_cli_server_start($code = 'echo "Hello world";',
$no_router = FALSE)
);
if (substr(PHP_OS, 0, 3) == 'WIN') {
- $cmd = "{$php_executable} -t {$doc_root} -n -S " . PHP_CLI_SERVER_ADDRESS;
+ $cmd = "{$php_executable} -t {$doc_root} -n {$cmd_args} -S " . PHP_CLI_SERVER_ADDRESS;
if (!$no_router) {
$cmd .= " {$router}";
}
$handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, $doc_root, NULL,
array("bypass_shell" => true, "suppress_errors" => true));
} else {
- $cmd = "exec {$php_executable} -t {$doc_root} -n -S " . PHP_CLI_SERVER_ADDRESS;
+ $cmd = "exec {$php_executable} -t {$doc_root} -n {$cmd_args} -S " .
PHP_CLI_SERVER_ADDRESS;
if (!$no_router) {
$cmd .= " {$router}";
}
diff --git a/sapi/cli/tests/upload_2G.phpt b/sapi/cli/tests/upload_2G.phpt
new file mode 100644
index 0000000..fe13d90
--- /dev/null
+++ b/sapi/cli/tests/upload_2G.phpt
@@ -0,0 +1,99 @@
+--TEST--
+file upload greater than 2G
+--SKIPIF--
+<?php
+include "skipif.inc";
+
+if (PHP_INT_SIZE < 8) {
+ die("skip need PHP_INT_SIZE>=8");
+}
+
+if ($f = fopen("/proc/meminfo","r")) {
+ while (!feof($f)) {
+ if (!strncmp($line = fgets($f), "MemFree", 7)) {
+ if (substr($line,8)/1024/1024 > 3) {
+ $enough_free_ram = true;
+ }
+ }
+ }
+}
+
+if (empty($enough_free_ram)) {
+ die("need +3G free RAM");
+}
+?>
+--FILE--
+<?php
+
+echo "Test\n";
+
+include "php_cli_server.inc";
+
+php_cli_server_start("var_dump(\$_FILES);", false,
+ "-d post_max_size=3G -d upload_max_filesize=3G");
+
+list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
+$port = intval($port)?:80;
+$length = 2150000000;
+$output = "";
+
+$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
+if (!$fp) {
+ die("connect failed");
+}
+
+$prev = "----123
+Content-Type: text/plain
+Content-Disposition: form-data; name=\"file1\";
filename=\"file1.txt\"\n\n";
+$post = "\n----123--\n";
+$total = $length + strlen($prev) + strlen($post);
+
+fwrite($fp, <<<EOF
+POST /index.php HTTP/1.1
+Host: {$host}
+Content-Type: multipart/form-data; boundary=--123
+Content-Length: {$total}
+
+{$prev}
+EOF
+) or die("write prev failed");
+
+$data = str_repeat("0123456789", 10000);
+for ($i = 0; $i < $length; $i += 10000 * 10) {
+ fwrite($fp, $data) or die("write failed @ ($i)");
+}
+
+fwrite($fp, $post) or die("write post failed");
+
+while (!feof($fp)) {
+ $output .= fgets($fp);
+}
+echo $output;
+fclose($fp);
+?>
+Done
+--EXPECTF--
+Test
+
+HTTP/1.1 200 OK
+Host: %s
+Connection: close
+X-Powered-By: PHP/%s
+Content-type: text/html
+
+array(1) {
+ ["file1"]=>
+ array(5) {
+ ["name"]=>
+ string(9) "file1.txt"
+ ["type"]=>
+ string(10) "text/plain"
+ ["tmp_name"]=>
+ string(14) "/tmp/php%s"
+ ["error"]=>
+ int(0)
+ ["size"]=>
+ int(2150000000)
+ }
+}
+Done