#45503 [NEW]: Content of HTTP POST Message not accessible w/ PHP

From: Date: Sun, 13 Jul 2008 22:03:05 +0000
Subject: #45503 [NEW]: Content of HTTP POST Message not accessible w/ PHP
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-126646@lists.php.net to get a copy of this message
From: michael at mcihael-menzel dot com Operating system: debian linux PHP version: 5.2.6 PHP Bug Type: HTTP related Bug description: Content of HTTP POST Message not accessible w/ PHP Description: ------------ when recieving POST HTTP messages which have text/xml content in the message body this content can't be accessed: - php://input is empty - $HTTP_RAW_POST_DATA is empty (though enabled in php.ini) - neither do $_POST, $_SERVER and $_REQUEST not contain the data (as expected and correct) - neither does $_FILE contain anything (last obvious possibility) - even installation of pecl extension pecl_http 1.6 can't solve it (none of the given functions/methods did work) Reproduce code: --------------- $headers = getHeaders(); $ch = curl_init(); $headers[Host] = ""; # to be filled with a XML webservice URL curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_URL, ""); # to be filled with a XML webservice URL curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents("php://input")); # replace with any method/function to get the POST content curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $httpContent = curl_exec($ch); curl_close($ch); echo $httpContent; $h = fopen("responsecontent.log", "a"); fwrite($h, "\n\n" . $httpContent); fclose($h); function getHeaders() { $h = fopen("headers.log", "a"); fwrite($h, "\n\n"); $headers = array(); foreach ($_SERVER as $k => $v) { if (substr($k, 0, 5) == "HTTP_") { $k = str_replace('_', ' ', substr($k, 5)); $k = str_replace(' ', '-', ucwords(strtolower($k))); $headers[$k] = $v; fwrite($h, $k . ": " . $v . "\n"); } } fclose($h); return $headers; } Expected result: ---------------- XML webservice answers to the POST request forwarded with curl. "reproduce code" doesn't contain the line to test the contents. in the beginning of the script all possible places where the POST content might be placed by PHP are written to a file. The file only gets filled by IE requests which send the data in a second HTTP (TCP-, IP-) packet. Firefox sends the whole request with content-type: text/xml in one packet and content is not accessible. Actual result: -------------- empty response by curl due to the empty post content sent to the webservice -- Edit bug report at http://bugs.php.net/?id=45503&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45503&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45503&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45503&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45503&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45503&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45503&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45503&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45503&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45503&r=support Expected behavior: http://bugs.php.net/fix.php?id=45503&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45503&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45503&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45503&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45503&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45503&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45503&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45503&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45503&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45503&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45503&r=mysqlcfg

« previous php.bugs (#126646) next »