/** * Apply self to responce headers */ public final function assign() { ZHeaders::setHeader($this->m_key, $this->m_value); }
function output($a_mime = 'image/png') { ob_start(); imagepng($this->m_handle); $c = ob_get_contents(); ob_end_clean(); if ($a_mime) { ZHeaders::setHeader('Content-type', $a_mime); } ZHeaders::setHeader('Accept-Ranges', 'bytes'); ZHeaders::setHeader('Content-Length', strlen($c)); ZHeaders::setHeader('Content-MD5', md5($c)); echo $c; }
/** * Send header now * @return ZResponse */ public function &send_headers() { ZHeaders::setCode($this->m_code, $this->m_message); foreach ($this->m_headers as $h) { $h->send(); } return $this; }
public function output() { if (empty($this->m_type)) { $this->m_type = 'text/plain'; } $this->addHeader('Content-Type', $this->m_type . ($this->m_encoding ? '; charset=' . $this->m_encoding : null)); ZHeaders::setCode($this->m_code, $this->m_message); foreach ($this->m_headers as $h) { $h->send(); } echo $this->getContent(); }
/** * Send document headers * @param string $a_encoding * @return ZDocument */ public function &outputHeader($a_encoding = 'utf-8') { ZHeaders::setHeader('Content-Type', $this->getMime() . '; charset=' . $a_encoding); return $this; }
/** * Redirect * @param string $a_to String to redirect * @param bool $a_exit Exit now * @return ZApplication */ public function &redirect($a_to, $a_exit = true) { ZHeaders::setHeader('location', (string) $a_to); if ($a_exit) { exit(0); } return $this; }
public static final function setCode($a_key, $a_message = 'OK') { self::$m_code = $a_key; self::$m_message = $a_message; }
/** * Output responce */ public function output() { if (empty($this->m_type)) { $this->m_type = 'text/plain'; } $this->addHeader('Content-Type', $this->m_type . ($this->m_encoding ? '; charset=' . $this->m_encoding : null)); if ($this->m_cache == false) { $this->addHeaders(array('Date' => gmdate(DATE_RFC822, time()) . ' GMT', 'Expires' => 'Fri, 01 Jan 1990 00:00:00 GMT', 'Pragma' => 'no-cache', 'Cache-Control' => 'no-cache, must-revalidate')); } if ($this->m_code == 302 || $this->m_cache == 307) { $this->addHeaders(array('Date' => null, 'Expires' => null, 'Pragma' => null, 'Cache-Control' => null)); } $this->addHeader('Content-length', $this->getContentLength()); ZHeaders::setCode($this->m_code, $this->m_message); foreach ($this->m_headers as $h) { $h->send(); } echo $this->m_content; }