You are here

public function ResponseHeaderBag::set in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/http-foundation/ResponseHeaderBag.php \Symfony\Component\HttpFoundation\ResponseHeaderBag::set()

Sets a header by name.

Parameters

string $key The key:

string|array $values The value or an array of values:

bool $replace Whether to replace the actual value or not (true by default):

Overrides HeaderBag::set

2 calls to ResponseHeaderBag::set()
ResponseHeaderBag::replace in vendor/symfony/http-foundation/ResponseHeaderBag.php
Replaces the current HTTP headers by a new set.
ResponseHeaderBag::__construct in vendor/symfony/http-foundation/ResponseHeaderBag.php
Constructor.

File

vendor/symfony/http-foundation/ResponseHeaderBag.php, line 98

Class

ResponseHeaderBag
ResponseHeaderBag is a container for Response HTTP headers.

Namespace

Symfony\Component\HttpFoundation

Code

public function set($key, $values, $replace = true) {
  parent::set($key, $values, $replace);
  $uniqueKey = strtr(strtolower($key), '_', '-');
  $this->headerNames[$uniqueKey] = $key;

  // ensure the cache-control header has sensible defaults
  if (in_array($uniqueKey, array(
    'cache-control',
    'etag',
    'last-modified',
    'expires',
  ))) {
    $computed = $this
      ->computeCacheControlValue();
    $this->headers['cache-control'] = array(
      $computed,
    );
    $this->headerNames['cache-control'] = 'Cache-Control';
    $this->computedCacheControl = $this
      ->parseCacheControl($computed);
  }
}