function restful_parse_request in RESTful 7
Build the request array from PHP globals and input stream.
Return value
array The request array.
2 calls to restful_parse_request()
- restful_menu_access_callback in ./
restful.module - Access callback; Determine access for an API call.
- restful_menu_process_callback in ./
restful.module - Page callback; Return the response for an API call.
File
- ./
restful.module, line 568
Code
function restful_parse_request() {
$request =& drupal_static(__FUNCTION__, NULL);
if ($request) {
return $request;
}
$method = strtoupper($_SERVER['REQUEST_METHOD']);
if ($method == \RestfulInterface::GET) {
$request = $_GET;
}
elseif ($method == \RestfulInterface::POST) {
$request = $_POST;
}
if (!$request && ($query_string = _restful_get_query_string_from_php_input())) {
// When trying to POST using curl on simpleTest it doesn't reach
// $_POST, so we try to re-grab it here.
// Also, sometimes the client might send the input still encoded.
if ($decoded_json = drupal_json_decode($query_string)) {
$request = $decoded_json;
}
else {
parse_str($query_string, $request);
}
}
// This flag is used to identify if the request is done "via Drupal" or "via
// CURL";
$request['__application'] = array(
'rest_call' => TRUE,
'csrf_token' => \RestfulManager::getRequestHttpHeader('X-CSRF-Token'),
);
// Allow implementing modules to alter the request.
drupal_alter('restful_parse_request', $request);
return $request;
}