Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pix0r/655839 to your computer and use it in GitHub Desktop.
Save pix0r/655839 to your computer and use it in GitHub Desktop.
/**
* Added to override the default parse_str(php://input)
*/
if (!empty($_SERVER['REQUEST_METHOD'])
&& in_array($_SERVER['REQUEST_METHOD'], array('GET', 'POST')) === false
&& empty($_POST)) {
// Store original request
$input = file_get_contents('php://input');
// Maintain compatibility with standard key/value data format
parse_str($input, $_POST);
// Store original data in $_POST[data]
$_POST['RAW_DATA'] = $input;
unset($input);
// Save this for later; it will be clobbered by Request::instance()
$_POST_save = $_POST;
}
/**
* Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
* If no source is specified, the URI will be automatically detected.
*/
$request = Request::instance();
/**
* In the event that Request::instance() clobbers $_POST, restore it
*/
if (!empty($_POST_save) && count($_POST_save) > count($_POST)) {
$_POST = $_POST_save;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment