diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-02-12 20:38:06 +0100 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-02-12 20:40:52 +0100 |
commit | 45bb6f5fd49cc5f86107176cf34f1b097698ed72 (patch) | |
tree | c962a0ef2c1f787787aabb4e07cb7a5f273864d7 /lib/response.php | |
parent | ee7931f457177d20f798b13911eb54fa92423f2f (diff) | |
download | nextcloud-server-45bb6f5fd49cc5f86107176cf34f1b097698ed72.tar.gz nextcloud-server-45bb6f5fd49cc5f86107176cf34f1b097698ed72.zip |
OC_Response: add redirect function
Diffstat (limited to 'lib/response.php')
-rw-r--r-- | lib/response.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/response.php b/lib/response.php index c254ddd10e7..5f095a0affd 100644 --- a/lib/response.php +++ b/lib/response.php @@ -7,7 +7,9 @@ */ class OC_Response { + const STATUS_FOUND = 304; const STATUS_NOT_MODIFIED = 304; + const STATUS_TEMPORARY_REDIRECT = 307; static public function enableCaching() { header('Cache-Control: cache'); @@ -15,12 +17,29 @@ class OC_Response { } static public function setStatus($status) { + $protocol = $_SERVER['SERVER_PROTOCOL']; switch($status) { case self::STATUS_NOT_MODIFIED: $status = $status . ' Not Modified'; break; + case self::STATUS_TEMPORARY_REDIRECT: + if ($protocol == 'HTTP/1.1') { + $status = $status . ' Temporary Redirect'; + break; + } else { + $status = self::STATUS_FOUND; + // fallthrough + } + case self::STATUS_FOUND; + $status = $status . ' Found'; + break; } - header($_SERVER["SERVER_PROTOCOL"].' '.$status); + header($protocol.' '.$status); + } + + static public function redirect($location) { + self::setStatus(self::STATUS_TEMPORARY_REDIRECT); + header('Location: '.$location); } static public function setETagHeader($etag) { |