|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-07-14 09:59 UTC] jani@php.net
[2008-07-22 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 19:00:01 2025 UTC |
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