ResponseHeaderBag
extends HeaderBag
in package
ResponseHeaderBag is a container for Response HTTP headers.
Tags
Table of Contents
- COOKIES_ARRAY = 'array'
- COOKIES_FLAT = 'flat'
- DISPOSITION_ATTACHMENT = 'attachment'
- DISPOSITION_INLINE = 'inline'
- LOWER = '-abcdefghijklmnopqrstuvwxyz'
- UPPER = '_ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- $cacheControl : mixed
- $computedCacheControl : mixed
- $cookies : mixed
- $headerNames : mixed
- $headers : array<string, array<int, string|null>>
- __construct() : mixed
- __toString() : string
- Returns the headers as a string.
- add() : mixed
- Adds new headers the current HTTP headers set.
- addCacheControlDirective() : mixed
- Adds a custom Cache-Control directive.
- all() : array<string, array<int, string|null>>|array<int, string|null>
- Returns the headers.
- allPreserveCase() : array<string|int, mixed>
- Returns the headers, with original capitalizations.
- allPreserveCaseWithoutCookies() : mixed
- clearCookie() : mixed
- Clears a cookie in the browser.
- contains() : bool
- Returns true if the given HTTP header contains the given value.
- count() : int
- Returns the number of headers.
- get() : string|null
- Returns the first header by name or the default one.
- getCacheControlDirective() : bool|string|null
- Returns a Cache-Control directive value by name.
- getCookies() : array<string|int, Cookie>
- Returns an array with all cookies.
- getDate() : DateTimeInterface|null
- Returns the HTTP header value converted to a date.
- getIterator() : ArrayIterator<string, array<int, string|null>>
- Returns an iterator for headers.
- has() : bool
- Returns true if the HTTP header is defined.
- hasCacheControlDirective() : bool
- Returns true if the Cache-Control directive is defined.
- keys() : array<string|int, string>
- Returns the parameter keys.
- makeDisposition() : mixed
- remove() : mixed
- Removes a header.
- removeCacheControlDirective() : mixed
- Removes a Cache-Control directive.
- removeCookie() : mixed
- Removes a cookie from the array, but does not unset it in the browser.
- replace() : mixed
- Replaces the current HTTP headers by a new set.
- set() : mixed
- Sets a header by name.
- setCookie() : mixed
- computeCacheControlValue() : string
- Returns the calculated value of the cache-control header.
- getCacheControlHeader() : mixed
- parseCacheControl() : array<string|int, mixed>
- Parses a Cache-Control HTTP header.
- initDate() : void
Constants
COOKIES_ARRAY
public
mixed
COOKIES_ARRAY
= 'array'
COOKIES_FLAT
public
mixed
COOKIES_FLAT
= 'flat'
DISPOSITION_ATTACHMENT
public
mixed
DISPOSITION_ATTACHMENT
= 'attachment'
DISPOSITION_INLINE
public
mixed
DISPOSITION_INLINE
= 'inline'
LOWER
protected
mixed
LOWER
= '-abcdefghijklmnopqrstuvwxyz'
UPPER
protected
mixed
UPPER
= '_ABCDEFGHIJKLMNOPQRSTUVWXYZ'
Properties
$cacheControl
protected
mixed
$cacheControl
= []
$computedCacheControl
protected
mixed
$computedCacheControl
= []
$cookies
protected
mixed
$cookies
= []
$headerNames
protected
mixed
$headerNames
= []
$headers
protected
array<string, array<int, string|null>>
$headers
= []
Methods
__construct()
public
__construct([array<string|int, mixed> $headers = [] ]) : mixed
Parameters
- $headers : array<string|int, mixed> = []
Return values
mixed —__toString()
Returns the headers as a string.
public
__toString() : string
Return values
string —add()
Adds new headers the current HTTP headers set.
public
add(array<string|int, mixed> $headers) : mixed
Parameters
- $headers : array<string|int, mixed>
Return values
mixed —addCacheControlDirective()
Adds a custom Cache-Control directive.
public
addCacheControlDirective(string $key[, bool|string $value = true ]) : mixed
Parameters
- $key : string
- $value : bool|string = true
-
The Cache-Control directive value
Return values
mixed —all()
Returns the headers.
public
all([string|null $key = null ]) : array<string, array<int, string|null>>|array<int, string|null>
Parameters
- $key : string|null = null
-
The name of the headers to return or null to get them all
Return values
array<string, array<int, string|null>>|array<int, string|null> —allPreserveCase()
Returns the headers, with original capitalizations.
public
allPreserveCase() : array<string|int, mixed>
Return values
array<string|int, mixed> —allPreserveCaseWithoutCookies()
public
allPreserveCaseWithoutCookies() : mixed
Return values
mixed —clearCookie()
Clears a cookie in the browser.
public
clearCookie(string $name[, string|null $path = '/' ][, string|null $domain = null ][, bool $secure = false ][, bool $httpOnly = true ][, string|null $sameSite = null ]) : mixed
Parameters
- $name : string
- $path : string|null = '/'
- $domain : string|null = null
- $secure : bool = false
- $httpOnly : bool = true
- $sameSite : string|null = null
Return values
mixed —contains()
Returns true if the given HTTP header contains the given value.
public
contains(string $key, string $value) : bool
Parameters
- $key : string
- $value : string
Return values
bool —count()
Returns the number of headers.
public
count() : int
Return values
int —get()
Returns the first header by name or the default one.
public
get(string $key[, string|null $default = null ]) : string|null
Parameters
- $key : string
- $default : string|null = null
Return values
string|null —getCacheControlDirective()
Returns a Cache-Control directive value by name.
public
getCacheControlDirective(string $key) : bool|string|null
Parameters
- $key : string
Return values
bool|string|null —getCookies()
Returns an array with all cookies.
public
getCookies([string $format = self::COOKIES_FLAT ]) : array<string|int, Cookie>
Parameters
- $format : string = self::COOKIES_FLAT
Tags
Return values
array<string|int, Cookie> —getDate()
Returns the HTTP header value converted to a date.
public
getDate(string $key[, DateTime|null $default = null ]) : DateTimeInterface|null
Parameters
- $key : string
- $default : DateTime|null = null
Tags
Return values
DateTimeInterface|null —getIterator()
Returns an iterator for headers.
public
getIterator() : ArrayIterator<string, array<int, string|null>>
Return values
ArrayIterator<string, array<int, string|null>> —has()
Returns true if the HTTP header is defined.
public
has(string $key) : bool
Parameters
- $key : string
Return values
bool —hasCacheControlDirective()
Returns true if the Cache-Control directive is defined.
public
hasCacheControlDirective(string $key) : bool
Parameters
- $key : string
Return values
bool —keys()
Returns the parameter keys.
public
keys() : array<string|int, string>
Return values
array<string|int, string> —makeDisposition()
public
makeDisposition(string $disposition, string $filename[, string $filenameFallback = '' ]) : mixed
Parameters
- $disposition : string
- $filename : string
- $filenameFallback : string = ''
Tags
Return values
mixed —remove()
Removes a header.
public
remove(string $key) : mixed
Parameters
- $key : string
Return values
mixed —removeCacheControlDirective()
Removes a Cache-Control directive.
public
removeCacheControlDirective(string $key) : mixed
Parameters
- $key : string
Return values
mixed —removeCookie()
Removes a cookie from the array, but does not unset it in the browser.
public
removeCookie(string $name[, string|null $path = '/' ][, string|null $domain = null ]) : mixed
Parameters
- $name : string
- $path : string|null = '/'
- $domain : string|null = null
Return values
mixed —replace()
Replaces the current HTTP headers by a new set.
public
replace([array<string|int, mixed> $headers = [] ]) : mixed
Parameters
- $headers : array<string|int, mixed> = []
Return values
mixed —set()
Sets a header by name.
public
set(string $key, mixed $values[, bool $replace = true ]) : mixed
Parameters
- $key : string
- $values : mixed
-
The value or an array of values
- $replace : bool = true
-
Whether to replace the actual value or not (true by default)
Return values
mixed —setCookie()
public
setCookie(Cookie $cookie) : mixed
Parameters
- $cookie : Cookie
Return values
mixed —computeCacheControlValue()
Returns the calculated value of the cache-control header.
protected
computeCacheControlValue() : string
This considers several other headers and calculates or modifies the cache-control header to a sensible, conservative value.
Return values
string —getCacheControlHeader()
protected
getCacheControlHeader() : mixed
Return values
mixed —parseCacheControl()
Parses a Cache-Control HTTP header.
protected
parseCacheControl(string $header) : array<string|int, mixed>
Parameters
- $header : string
Return values
array<string|int, mixed> —initDate()
private
initDate() : void