Source for file Response.class.php
Documentation is available at Response.class.php
* @copyright Energine 2006
//require_once('core/framework/Object.class.php');
* @var Response единый для всей системы экземпляр класса Response
private static $instance;
* @var string строка статуса ответа
* @var array заголовки ответа
* @var array cookies ответа
* @var string тело ответа
* @var array описание кодов ответа
101 => 'Switching Protocols',
203 => 'Non-Authoritative Information',
206 => 'Partial Content',
300 => 'Multiple Choices',
301 => 'Moved Permanently',
307 => 'Temporary Redirect',
402 => 'Payment Required',
405 => 'Method Not Allowed',
407 => 'Proxy Authentication Required',
408 => 'Request Time-out',
411 => 'Length Required',
412 => 'Precondition Failed',
413 => 'Request Entity Too Large',
414 => 'Request-URI Too Large',
415 => 'Unsupported Media Type',
416 => 'Requested range not satisfiable',
417 => 'Expectation Failed',
500 => 'Internal Server Error',
501 => 'Not Implemented',
503 => 'Service Unavailable',
504 => 'Gateway Time-out',
505 => 'HTTP Version not supported'
* Возвращает единый для всей системы экземпляр класса Response.
if (!isset (self::$instance)) {
self::$instance = new Response;
* Устанавливает статус ответа.
* @param string $reasonPhrase
public function setStatus($statusCode, $reasonPhrase = null) {
if (!isset ($reasonPhrase)) {
$this->statusLine = $_SERVER['SERVER_PROTOCOL']. " $statusCode $reasonPhrase";
* Устанавливает поле заголовка ответа.
* @param boolean $replace
public function setHeader($name, $value, $replace = true) {
if ((!$replace) && isset ($this->headers[$name])) {
public function setCookie($name, $value = '', $expire = '', $path = '', $domain = '', $secure = false) {
$this->cookies[$name] = compact('value', 'expire', 'path', 'domain', 'secure');
public function deleteCookie($name, $path = '', $domain = '', $secure = false) {
$this->setCookie($name, '', (time() - 1), $path, $domain, $secure);
* Устанавливает адрес для переадресации.
* @param string $location
* Устанавливает адрес переадресации
if ($action && substr($action, - 1) !== '/') {
. $request->getLangSegment()
. $request->getPath(Request::PATH_TEMPLATE, true)
* Добавляет данные к телу ответа.
public function write($data) {
* Отправляет ответ клиенту и завершает работу программы.
foreach ($this->headers as $name => $value) {
foreach ($this->cookies as $name => $params) {
setcookie($name, $params['value'], $params['expire'], $params['path'], $params['domain'], $params['secure']);
//throw new SystemException('ERR_HEADERS_SENT', SystemException::ERR_CRITICAL, array($filename, $linenum));
header("Vary: Accept-Encoding");
header("Content-Encoding: gzip");
|