public function Response::sendHeaders

Sends HTTP headers.

Return value

Response

1 call to Response::sendHeaders()
Response::send in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php
Sends HTTP headers and content.

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php, line 251

Class

Response
Response represents an HTTP response.

Namespace

Symfony\Component\HttpFoundation

Code

public function sendHeaders() {

  // headers have already been sent by the developer
  if (headers_sent()) {
    return $this;
  }

  // status
  header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText));

  // headers
  foreach ($this->headers
    ->all() as $name => $values) {
    foreach ($values as $value) {
      header($name . ': ' . $value, false);
    }
  }

  // cookies
  foreach ($this->headers
    ->getCookies() as $cookie) {
    setcookie($cookie
      ->getName(), $cookie
      ->getValue(), $cookie
      ->getExpiresTime(), $cookie
      ->getPath(), $cookie
      ->getDomain(), $cookie
      ->isSecure(), $cookie
      ->isHttpOnly());
  }
  return $this;
}