From 89703491002223f3a7fa789ef0225d0641d3aa6d Mon Sep 17 00:00:00 2001 From: Bruce Alderson Date: Thu, 8 Aug 2013 13:53:04 -0700 Subject: [PATCH] Extended redirects to include redirect code (and parameters). --- lib/response.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/response.php b/lib/response.php index d8806ea..f149318 100644 --- a/lib/response.php +++ b/lib/response.php @@ -129,9 +129,18 @@ public function hdr($c = '200', $h = null) { return true; } - /* Redirect client */ - public function redirect($t = '500.html', $o = null) { + /* Redirect client - target, status code, and options */ + public function redirect($t = '500.html', $c = '302', $o = null) { + $message = array_key_exists($c, $this->codes) ? $this->codes[$c] + : 'Internal error'; + $v = defined('SERVICE_VERSION') ? SERVICE_VERSION : PRESTO_VERSION; + + header("HTTP/1.0 {$c} {$message}", true, $c); + header(VERSION_HEADER . ': ' . $v); + header('Cache-Control: no-cache'); + $opt = isset($o) ? '?' . http_build_query($o) : ''; + return header("Location: /$t$opt"); exit; }