HTTP_RAW_POST_DATA on PHP5.3.x issue

HTTP_RAW_POST_DATA on PHP5.3.x issue
issue on HTTP_RAW_POST_DATA was empty set on process

Problem is :

Script receives gzipped data from a desktop application via POST, which it retrieves and processes from $HTTP_RAW_POST_DATA. In PHP 5.2.16 (ISAPI), $HTTP_RAW_POST_DATA is correctly being populated with the expected binary data. After upgrading to PHP 5.3.9 (FastCGI), $HTTP_RAW_POST_DATA is not defined. How can I get the data?

Answer :

The docs regarding $HTTP_RAW_POST_DATA state that it 'is not available with enctype="multipart/form-data"', but I'm not using that content type. (Recall that the same code works fine under PHP 5.2, so content type would have been a problem then, too.)

When I enabled the always_populate_raw_post_data ini directive, nothing changes. phpinfo() reports that setting as "On", but the variable is still not being set.

The docs also suggest that the preferred method to obtain this data is to read it from the php://input stream instead. I tried that as follows:

$HTTP_RAW_POST_DATA = file_get_contents('php://input');

but the script just hangs on that line, presumably because it's waiting for data (i.e., no End-Of-File sent). Even if I limit the maxlength to a value as small as one byte as follows, it still hangs.

$HTTP_RAW_POST_DATA = file_get_contents('php://input', false, null, -1, 1);

The only time it doesn't hang on that line is when I set the maxlen to 0, which means it doesn't try to read anything but also isn't helpful. :-)

If $HTTP_RAW_POST_DATA won't populate when I force it to, and I can't get anything from php://input, how can I get the data?

Is the fact that php://input is apparently empty indicative of a difference between ISAPI and FastCGI? I haven't read anything suggesting that raw POSTs behave differently or are lost under FastCGI.



Suggest :

if ( !isset( $HTTP_RAW_POST_DATA ) ) {$HTTP_RAW_POST_DATA =file_get_contents( 'php://input' ); //echo "WOke";
//print_r($HTTP_RAW_POST_DATA);
$server->service($HTTP_RAW_POST_DATA);
}