Skip to content

Commit

Permalink
Fixed HTTP status codes for non-redirects which were breaking AuthCom…
Browse files Browse the repository at this point in the history
…ponent.
  • Loading branch information
Phally committed May 4, 2012
1 parent ed1a64c commit 7bb56e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
17 changes: 8 additions & 9 deletions lib/Cake/Controller/Controller.php
Expand Up @@ -531,7 +531,7 @@ protected function _getScaffold(CakeRequest $request) {
}

/**
* Merge components, helpers, and uses vars from
* Merge components, helpers, and uses vars from
* Controller::$_mergeParent and PluginAppController.
*
* @return void
Expand Down Expand Up @@ -770,18 +770,17 @@ public function redirect($url, $status = null, $exit = true) {
session_write_close();
}

if (!empty($status) && is_string($status)) {
$codes = array_flip($this->response->httpCodes());
if (isset($codes[$status])) {
$status = $codes[$status];
}
}

if ($url !== null) {
$this->response->header('Location', Router::url($url, true));
}

if (!empty($status) && ($status >= 300 && $status < 400)) {
if (!empty($status)) {
if (is_string($status)) {
$codes = array_flip($this->response->httpCodes());
if (isset($codes[$status])) {
$status = $codes[$status];
}
}
$this->response->statusCode($status);
}

Expand Down
5 changes: 3 additions & 2 deletions lib/Cake/Test/Case/Controller/ControllerTest.php
Expand Up @@ -387,7 +387,7 @@ class AnotherTestController extends ControllerTestAppController {

/**
* merge parent
*
*
* @var string
*/
protected $_mergeParent = 'ControllerTestAppController';
Expand Down Expand Up @@ -729,7 +729,8 @@ public static function statusCodeProvider() {
array(303, "See Other"),
array(304, "Not Modified"),
array(305, "Use Proxy"),
array(307, "Temporary Redirect")
array(307, "Temporary Redirect"),
array(403, "Forbidden"),
);
}

Expand Down

0 comments on commit 7bb56e7

Please sign in to comment.