Hi all, While porting improvements of run-tests.php into the pear run-tests command, I noticed that there are no tests for the php://input stream in PHP_5_2 (didn't look at HEAD yet), so I thought I would offer one if it is useful.
At the same time, I found a flaw in the implementation of POST_RAW, patch attached. Basically, \n is appended to all lines including the last line. The patch corrects this by appending \n to all but the last line so there is no trailing whitespace. Here's the new test: --TEST-- php://input --SKIPIF-- <?php if (php_sapi_name()=='cli') die('skip'); ?> --POST_RAW-- Content-Type: application/x-www-form-urlencoded userid=joe&password=guessme --FILE-- <?php var_dump($_FILES); var_dump($_POST); $fp = fopen('php://input', 'r'); $a = fread($fp, 8192); fclose($fp); var_dump($a); ?> --EXPECT-- array(0) { } array(2) { ["userid"]=> string(3) "joe" ["password"]=> string(7) "guessme" } string(27) "userid=joe&password=guessme"
Index: run-tests.php =================================================================== RCS file: /repository/php-src/run-tests.php,v retrieving revision 1.226.2.37.2.23 diff -u -r1.226.2.37.2.23 run-tests.php --- run-tests.php 8 Feb 2007 15:22:03 -0000 1.226.2.37.2.23 +++ run-tests.php 17 Feb 2007 04:22:32 -0000 @@ -1300,12 +1300,15 @@ $raw_lines = explode("\n", $post); $request = ''; + $started = false; foreach ($raw_lines as $line) { if (empty($env['CONTENT_TYPE']) && preg_match('/^Content-Type:(.*)/i', $line, $res)) { $env['CONTENT_TYPE'] = trim(str_replace("\r", '', $res[1])); continue; } - $request .= $line . "\n"; + if ($started) $request .= "\n"; + $started = true; + $request .= $line; } $env['CONTENT_LENGTH'] = strlen($request);
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php