public function sendHttpHeaders()
{
if (!$this->options['send_http_headers']) {
return;
}
// status
$status = $this->options['http_protocol'] . ' ' . $this->statusCode . ' ' . $this->statusText;
header($status);
if (substr(php_sapi_name(), 0, 3) == 'cgi') {
// fastcgi servers cannot send this status information because it was sent by them already due to the HTT/1.0 line
// so we can safely unset them. see ticket #3191
unset($this->headers['Status']);
}
if ($this->options['logging']) {
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Send status "%s"', $status))));
}
// headers
if (!$this->getHttpHeader('Content-Type')) {
$this->setContentType($this->options['content_type']);
}
foreach ($this->headers as $name => $value) {
header($name . ': ' . $value);
if ($value != '' && $this->options['logging']) {
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Send header "%s: %s"', $name, $value))));
}
}
// cookies
foreach ($this->cookies as $cookie) {
setrawcookie($cookie['name'], $cookie['value'], $cookie['expire'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httpOnly']);
if ($this->options['logging']) {
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Send cookie "%s": "%s"', $cookie['name'], $cookie['value']))));
}
}
// prevent resending the headers
$this->options['send_http_headers'] = false;
}