MINOR Removed ability in PjaxResponseNegotiator to send non-JSON responses for single fragments, as we're now relying on the server communicating which segment needs replacement (through the JSON key)

This commit is contained in:
Ingo Schommer 2012-05-30 14:58:24 +02:00
parent 75e51de9ed
commit 1102bbdf17

View File

@ -53,18 +53,8 @@ class PjaxResponseNegotiator {
throw new SS_HTTPResponse_Exception("X-Pjax = '$fragment' not supported for this URL.", 400); throw new SS_HTTPResponse_Exception("X-Pjax = '$fragment' not supported for this URL.", 400);
} }
} }
if(count($responseParts) == 1) { $response->setBody(Convert::raw2json($responseParts));
$response->setBody(array_pop($responseParts)); $response->addHeader('Content-Type', 'text/json');
} else {
if($request->getHeader('Accept') != 'text/json') {
throw new SS_HTTPResponse_Exception(
'Multiple comma-separated fragments can only be returne with an "Accept: text/json" header',
400
);
}
$response->setBody(Convert::raw2json($responseParts));
$response->addHeader('Content-Type', 'text/json');
}
} else { } else {
if($request->isAjax()) throw new SS_HTTPResponse_Exception("Ajax requests to this URL require an X-Pjax header.", 400); if($request->isAjax()) throw new SS_HTTPResponse_Exception("Ajax requests to this URL require an X-Pjax header.", 400);
$response->setBody(call_user_func($callbacks['default'])); $response->setBody(call_user_func($callbacks['default']));