function ResponseHeaderBag::set
Overrides HeaderBag::set
3 calls to ResponseHeaderBag::set()
- ResponseHeaderBag::initDate in vendor/
symfony/ http-foundation/ ResponseHeaderBag.php - 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
File
-
vendor/
symfony/ http-foundation/ ResponseHeaderBag.php, line 100
Class
- ResponseHeaderBag
- ResponseHeaderBag is a container for Response HTTP headers.
Namespace
Symfony\Component\HttpFoundationCode
public function set(string $key, string|array|null $values, bool $replace = true) : void {
$uniqueKey = strtr($key, self::UPPER, self::LOWER);
if ('set-cookie' === $uniqueKey) {
if ($replace) {
$this->cookies = [];
}
foreach ((array) $values as $cookie) {
$this->setCookie(Cookie::fromString($cookie));
}
$this->headerNames[$uniqueKey] = $key;
return;
}
$this->headerNames[$uniqueKey] = $key;
parent::set($key, $values, $replace);
// ensure the cache-control header has sensible defaults
if (\in_array($uniqueKey, [
'cache-control',
'etag',
'last-modified',
'expires',
], true) && '' !== ($computed = $this->computeCacheControlValue())) {
$this->headers['cache-control'] = [
$computed,
];
$this->headerNames['cache-control'] = 'Cache-Control';
$this->computedCacheControl = $this->parseCacheControl($computed);
}
}