Merge pull request #152 from kijin/fuxml/dont-post-with-xml

XML 제거: 폼 제출시 불필요하게 XML을 사용하지 않도록 변경
This commit is contained in:
Kijin Sung 2016-01-27 13:32:54 +09:00
commit 9ee739aea7
6 changed files with 369 additions and 374 deletions

View file

@ -214,8 +214,8 @@ class Context
{
$GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input");
// If content is not XML JSON, unset
if(!preg_match('/^[\<\{\[]/', $GLOBALS['HTTP_RAW_POST_DATA']) && strpos($_SERVER['CONTENT_TYPE'], 'json') === FALSE && strpos($_SERVER['HTTP_CONTENT_TYPE'], 'json') === FALSE)
// If content is not XML or JSON, unset
if(!preg_match('/^[\<\{\[]/', $GLOBALS['HTTP_RAW_POST_DATA']))
{
unset($GLOBALS['HTTP_RAW_POST_DATA']);
}
@ -1276,7 +1276,7 @@ class Context
{
self::$_instance->request_method = $type;
}
elseif (strpos($_SERVER['CONTENT_TYPE'], 'json') !== false || strpos($_SERVER['HTTP_CONTENT_TYPE'], 'json') !== false)
elseif (strpos($_SERVER['HTTP_ACCEPT'], 'json') !== false || strpos($_SERVER['CONTENT_TYPE'], 'json') !== false || strpos($_SERVER['HTTP_CONTENT_TYPE'], 'json') !== false)
{
self::$_instance->request_method = 'JSON';
}
@ -1336,7 +1336,7 @@ class Context
{
$set_to_vars = TRUE;
}
elseif($requestMethod == 'POST' && isset($_POST[$key]))
elseif(($requestMethod == 'POST' || $requestMethod == 'JSON') && isset($_POST[$key]))
{
$set_to_vars = TRUE;
}
@ -1387,14 +1387,12 @@ class Context
*/
private function _setJSONRequestArgument()
{
if(self::getRequestMethod() != 'JSON')
if(count($_POST) || self::getRequestMethod() != 'JSON')
{
return;
}
$params = array();
parse_str($GLOBALS['HTTP_RAW_POST_DATA'], $params);
foreach($params as $key => $val)
{
self::set($key, $this->_filterRequestVar($key, $val, 1), TRUE);

View file

@ -91,7 +91,10 @@ class DisplayHandler extends Handler
{
if(Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK')
{
self::_printJSONHeader();
if(strpos($_SERVER['HTTP_ACCEPT'], 'json') !== false)
{
self::_printJSONHeader();
}
}
else if(Context::getResponseMethod() != 'HTML')
{