ID: 31417 Updated by: ras...@php.net Reported By: j-spam at starline dot ee Status: No Feedback Bug Type: CGI related Operating System: Linux PHP Version: 5.0.3 New Comment:
Daniel, that's the way it is supposed to work. By default $HTTP_RAW_POST_DATA is not populated if we see a known encoding. With a known encoding we decode it and populate $_POST. If you want to force $HTTP_RAW_POST_DATA to always be populated turn on always_populate_raw_post_data in your .ini Previous Comments: ------------------------------------------------------------------------ [2009-11-20 16:34:47] daniel dot kirsch at birgin dot de I run into the same problem with my ajax application. When using a XMLHTTPRequest instance I need to provide the data in the following way: key=value&anotherkey=anothervalue So each key/value pair is separated by "&". Additionally I need to define the correct request header which must be set after opening the connection and before sending the request: var postData = "key=value&anotherkey=anothervalue"; var ajax = new XMLHttpRequest(); ajax.open("POST",url,false); ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); ajax.send(postData); When doing it this way I receive the correct values in $_POST. $HTTP_RAW_POST_DATA is empty. When not defining the request header $HTTP_RAW_POST_DATA contains the data and $_POST is empty. ------------------------------------------------------------------------ [2008-05-22 20:46:34] mgb at matthewbelden dot com sorry in the previous comment the pattern should be \r\n not just \n ------------------------------------------------------------------------ [2008-05-22 18:57:33] mgb at matthewbelden dot com This workaround did it for me, the above did not. $pattern = "/\n/"; $replace = "&"; $GLOBALS['HTTP_RAW_POST_DATA'] = preg_replace($pattern, $replace, $GLOBALS['HTTP_RAW_POST_DATA']); if (isset($GLOBALS['HTTP_RAW_POST_DATA']) && !count($_POST)) parse_str($GLOBALS['HTTP_RAW_POST_DATA'] , $_POST); ------------------------------------------------------------------------ [2006-05-16 15:23:38] fabiovh at nospammers dot gmail dot com //workaround if (isset($GLOBALS['HTTP_RAW_POST_DATA']) && !count($_POST)) parse_str($GLOBALS['HTTP_RAW_POST_DATA'] , $_POST); ------------------------------------------------------------------------ [2006-05-15 14:53:58] baker195 at btinternet dot com I'm writing an AJAX application and after using the XLMHttpRequest object to post the data to my server side PHP script, I have to extract the data from $HTTP_RAW_POST_DATA as $_POST is empty. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/31417 -- Edit this bug report at http://bugs.php.net/?id=31417&edit=1