#45503 [Com]: Content of HTTP POST Message not accessible w/ PHP
| From: | 872431405 at qq dot com | Date: | Mon, 28 Dec 2009 05:56:58 +0000 |
| Subject: | #45503 [Com]: Content of HTTP POST Message not accessible w/ PHP | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-146148@lists.php.net to get a copy of this message | ||
ID: 45503
Comment by: 872431405 at qq dot com
Reported By: michael at mcihael-menzel dot com
Status: No Feedback
Bug Type: HTTP related
Operating System: debian linux
PHP Version: 5.2.6
New Comment:
one day i went shopping outside,and in an ed hardy store,I found some
kinds of ed hardy i love most they are Your website is really good Thank
you for the information <strong><a target="_blank"
href="http://www.abercrombie.us.com/men/classic-shirts">Abercrombie
And
Fitch Men Shirts</strong></a> Abercrombie And Fitch Men Shirts
<strong><a title=Ed Hardy Bags
href=http://www.ed-hardy-free.com/ed-hardy-accessories/bags
rel=dofollow>Ed Hardy Bags</strong></a> Ed Hardy Bags thank you for
information
Previous Comments:
------------------------------------------------------------------------
[2008-07-22 01:00:02] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2008-07-14 09:59:46] jani@php.net
So the problem is that you can't pass POST stuff to this script?
Where's that part in this example? You only included the irrelevant part
here, perhaps it would be more obvious if we saw the actual POST form
you use.
------------------------------------------------------------------------
[2008-07-13 22:03:05] michael at mcihael-menzel dot com
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 this bug report at http://bugs.php.net/?id=45503&edit=1