Browse Source

Adding redirect fix for Ticket #1951

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4400 3807eeeb-6ff5-0310-8944-8be069107fe0
nate 19 years ago
parent
commit
375276df4f
1 changed files with 17 additions and 4 deletions
  1. 17 4
      cake/libs/controller/controller.php

+ 17 - 4
cake/libs/controller/controller.php

@@ -400,7 +400,7 @@ class Controller extends Object {
 			session_write_close();
 		}
 
-		if (is_numeric($status) && $status > 0) {
+		if (!empty($status)) {
 			$codes = array(
 				100 => "Continue",
 				101 => "Switching Protocols",
@@ -440,15 +440,28 @@ class Controller extends Object {
 				501 => "Not Implemented",
 				502 => "Bad Gateway",
 				503 => "Service Unavailable",
-				504 => "Gateway Time-out");
-
+				504 => "Gateway Time-out"
+			);
+			if (is_string($status)) {
+				$codes = array_combine(array_values($codes), array_keys($codes));
+			}
 			if (isset($codes[$status])) {
-				header("HTTP/1.1 $status " . $codes[$status]);
+				$code = ife(is_numeric($status), $status, $codes[$status]);
+				$msg  = ife(is_string($status),  $status, $codes[$status]);
+				$status = "HTTP/1.1 {$code} {$msg}";
+			} else {
+				$status = null;
 			}
 		}
+		if (!empty($status)) {
+			header($status);
+		}
 		if ($url !== null) {
 			header('Location: ' . Router::url($url, true));
 		}
+		if (!empty($status)) {
+			header($status);
+		}
 		if ($exit) {
 			exit();
 		}