Making RequestHandler component carry along a passed status code. This fixes issues where RequestHandler hijacks an redirect(). Fixes #658

This commit is contained in:
Mark Story 2010-05-03 22:07:13 -04:00
parent c48f6d6536
commit 95dbae8acf
2 changed files with 25 additions and 5 deletions

View file

@ -262,7 +262,7 @@ class RequestHandlerComponent extends Object {
* @param mixed $url A string or array containing the redirect location
* @access public
*/
function beforeRedirect(&$controller, $url) {
function beforeRedirect(&$controller, $url, $status = null) {
if (!$this->isAjax()) {
return;
}
@ -272,6 +272,12 @@ class RequestHandlerComponent extends Object {
if (is_array($url)) {
$url = Router::url($url + array('base' => false));
}
if (!empty($status)) {
$statusCode = $controller->httpCodes($status);
$code = key($statusCode);
$msg = $statusCode[$code];
$controller->header("HTTP/1.1 {$code} {$msg}");
}
echo $this->requestAction($url, array('return'));
$this->_stop();
}