protected function redirect($uri) { $this->response->headers("Location", $this->app->url->site($uri)); }
/** * Sends headers to the php processor, or supplied `$callback` argument. * This method formats the headers correctly for output, re-instating their * capitalization for transmission. * * [!!] if you supply a custom header handler via `$callback`, it is * recommended that `$response` is returned * * @param HTTP_Response $response header to send * @param boolean $replace replace existing value * @param callback $callback optional callback to replace PHP header function * @return mixed * @since 3.2.0 */ public function send_headers(Response $response = NULL, $replace = FALSE, $callback = NULL) { $protocol = $response->protocol(); $status = $response->status(); // Create the response header $processed_headers = array($protocol . ' ' . $status . ' ' . $response->message($status)); // Get the headers array $headers = $response->headers()->getArrayCopy(); foreach ($headers as $header => $value) { if (is_array($value)) { $value = implode(', ', $value); } $processed_headers[] = Text::ucfirst($header) . ': ' . $value; } if (!isset($headers['content-type'])) { $processed_headers[] = 'Content-Type: text/html; charset=utf-8'; } // Get the cookies and apply if ($cookies = $response->cookie()) { $processed_headers['Set-Cookie'] = $cookies; } if (is_callable($callback)) { // Use the callback method to set header return call_user_func($callback, $response, $processed_headers, $replace); } else { $this->_send_headers_to_php($processed_headers, $replace); return $response; } }