|
@@ -265,7 +265,7 @@ class request_helper
|
|
|
{
|
|
|
$method = strtolower(request_helper::method());
|
|
|
$squery = request_helper::query_string();
|
|
|
- self::parse_formurl($squery,$method);
|
|
|
+ self::parse_fromurl($squery,$method);
|
|
|
|
|
|
if ($method == 'post') {
|
|
|
$content = request_helper::content();
|
|
@@ -275,9 +275,9 @@ class request_helper
|
|
|
if(!empty($content))
|
|
|
{
|
|
|
$content_type = strtolower(self::content_type());
|
|
|
- Log::record("type = {$content_type}, content={$content}",Log::DEBUG);
|
|
|
+ Log::record("type = $content_type, content=$content",Log::DEBUG);
|
|
|
|
|
|
- $checker = function ($stype)
|
|
|
+ $checker_form = function ($stype)
|
|
|
{
|
|
|
$formtypes = ['application/x-www-form-urlencoded', 'text/xml', 'text/html', 'multipart/form-data', 'application/octet-stream'];
|
|
|
foreach ($formtypes as $type) {
|
|
@@ -288,13 +288,31 @@ class request_helper
|
|
|
return false;
|
|
|
};
|
|
|
|
|
|
- if(empty($content_type) || $checker($content_type)) {
|
|
|
- self::parse_formurl($content,$method);
|
|
|
+ $checker_json = function ($stype)
|
|
|
+ {
|
|
|
+ $formtypes = ['application/json'];
|
|
|
+ foreach ($formtypes as $type) {
|
|
|
+ if(self::start_with($stype,$type)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ };
|
|
|
+
|
|
|
+ if (empty($content_type) || $checker_form($content_type)) {
|
|
|
+ self::parse_fromurl($content, $method);
|
|
|
+ } elseif ($checker_json($content_type)) {
|
|
|
+ $values = json_decode($content, true);
|
|
|
+ foreach ($values as $key => $val) {
|
|
|
+ $_GET[$key] = $val;
|
|
|
+ $_POST[$key] = $val;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- static private function parse_formurl($squery,$method)
|
|
|
+
|
|
|
+ static private function parse_fromurl($squery,$method)
|
|
|
{
|
|
|
if(empty($squery)) return;
|
|
|
|