Be more consistent about JSON responses

cf. #152
This commit is contained in:
Kijin Sung 2020-10-08 13:25:46 +09:00
parent 7cede70de0
commit 8cabb88dbb

View file

@ -100,19 +100,16 @@ class DisplayHandler extends Handler
// header output // header output
$httpStatusCode = $oModule->getHttpStatusCode(); $httpStatusCode = $oModule->getHttpStatusCode();
if($httpStatusCode !== 200 && !in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON', 'JS_CALLBACK'))) if($httpStatusCode !== 200 && !in_array(Context::getResponseMethod(), array('XMLRPC', 'JSON', 'JS_CALLBACK')))
{ {
self::_printHttpStatusCode($httpStatusCode); self::_printHttpStatusCode($httpStatusCode);
} }
else else
{ {
if(Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK' || isset($_POST['_rx_ajax_compat'])) if(Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK' || isset($_POST['_rx_ajax_compat']))
{
if(strpos($_SERVER['HTTP_ACCEPT'], 'json') !== false)
{ {
self::_printJSONHeader(); self::_printJSONHeader();
} }
}
elseif(Context::getResponseMethod() == 'XMLRPC') elseif(Context::getResponseMethod() == 'XMLRPC')
{ {
self::_printXMLHeader(); self::_printXMLHeader();