Allow JSON requests with actual JSON payload

This commit is contained in:
Kijin Sung 2020-07-02 16:13:31 +09:00
parent 945c09059a
commit dd603639e0

View file

@ -1051,11 +1051,11 @@ class Context
*/ */
public static function convertEncodingStr($str) public static function convertEncodingStr($str)
{ {
if (!$str || utf8_check($str)) if (!$str || utf8_check($str))
{ {
return $str; return $str;
} }
$obj = new stdClass; $obj = new stdClass;
$obj->str = $str; $obj->str = $str;
$obj = self::convertEncoding($obj); $obj = self::convertEncoding($obj);
@ -1254,8 +1254,16 @@ class Context
} }
elseif(self::getRequestMethod() === 'JSON') elseif(self::getRequestMethod() === 'JSON')
{ {
$params = array(); if(substr($GLOBALS['HTTP_RAW_POST_DATA'], 0, 1) === '{' && substr($GLOBALS['HTTP_RAW_POST_DATA'], -1, 1) === '}')
parse_str($GLOBALS['HTTP_RAW_POST_DATA'], $params); {
$params = json_decode($GLOBALS['HTTP_RAW_POST_DATA']);
}
else
{
$params = array();
parse_str($GLOBALS['HTTP_RAW_POST_DATA'], $params);
}
foreach($params as $key => $val) foreach($params as $key => $val)
{ {
if (isset($request_args[$key])) if (isset($request_args[$key]))