FileAccess Orion

ResponseHeaderBag extends HeaderBag
in package

ResponseHeaderBag is a container for Response HTTP headers.

Tags
author

Fabien Potencier fabien@symfony.com

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  : mixed
__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|int, mixed>
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 a header value by name.
getCacheControlDirective()  : mixed|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
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, mixed>
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

LOWER

protected mixed LOWER = '-abcdefghijklmnopqrstuvwxyz'

UPPER

protected mixed UPPER = '_ABCDEFGHIJKLMNOPQRSTUVWXYZ'

Properties

$cacheControl

protected mixed $cacheControl = []

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

The headers

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[, mixed $value = true ]) : mixed
Parameters
$key : string

The Cache-Control directive name

$value : mixed = true

The Cache-Control directive value

Return values
mixed

all()

Returns the headers.

public all() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of headers

allPreserveCase()

Returns the headers, with original capitalizations.

public allPreserveCase() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of headers

allPreserveCaseWithoutCookies()

public allPreserveCaseWithoutCookies() : mixed
Return values
mixed

clearCookie()

Clears a cookie in the browser.

public clearCookie(string $name[, string $path = '/' ][, string $domain = null ][, bool $secure = false ][, bool $httpOnly = true ]) : mixed
Parameters
$name : string
$path : string = '/'
$domain : string = null
$secure : bool = false
$httpOnly : bool = true
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

The HTTP header name

$value : string

The HTTP value

Return values
bool

true if the value is contained in the header, false otherwise

count()

Returns the number of headers.

public count() : int
Return values
int

The number of headers

get()

Returns a header value by name.

public get(string $key[, string|null $default = null ]) : string|null
Parameters
$key : string

The header name

$default : string|null = null

The default value

Return values
string|null

The first header value or default value

getCacheControlDirective()

Returns a Cache-Control directive value by name.

public getCacheControlDirective(mixed $key) : mixed|null
Parameters
$key : mixed

The directive name

Return values
mixed|null

The directive value if defined, null otherwise

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
throws
InvalidArgumentException

When the $format is invalid

Return values
array<string|int, Cookie>

getDate()

Returns the HTTP header value converted to a date.

public getDate(string $key[, DateTime $default = null ]) : DateTimeInterface|null
Parameters
$key : string

The parameter key

$default : DateTime = null
Tags
throws
RuntimeException

When the HTTP header is not parseable

Return values
DateTimeInterface|null

The parsed DateTime or the default value if the header does not exist

getIterator()

Returns an iterator for headers.

public getIterator() : ArrayIterator
Return values
ArrayIterator

An \ArrayIterator instance

has()

Returns true if the HTTP header is defined.

public has(string $key) : bool
Parameters
$key : string

The HTTP header

Return values
bool

true if the parameter exists, false otherwise

hasCacheControlDirective()

Returns true if the Cache-Control directive is defined.

public hasCacheControlDirective(mixed $key) : bool
Parameters
$key : mixed

The Cache-Control directive

Return values
bool

true if the directive exists, false otherwise

keys()

Returns the parameter keys.

public keys() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of parameter keys

makeDisposition()

public makeDisposition(mixed $disposition, mixed $filename[, mixed $filenameFallback = '' ]) : mixed
Parameters
$disposition : mixed
$filename : mixed
$filenameFallback : mixed = ''
Tags
see
HeaderUtils::makeDisposition()
Return values
mixed

remove()

Removes a header.

public remove(mixed $key) : mixed
Parameters
$key : mixed

The HTTP header name

Return values
mixed

removeCacheControlDirective()

Removes a Cache-Control directive.

public removeCacheControlDirective(string $key) : mixed
Parameters
$key : string

The Cache-Control directive

Return values
mixed

removeCookie()

Removes a cookie from the array, but does not unset it in the browser.

public removeCookie(string $name[, string $path = '/' ][, string $domain = null ]) : mixed
Parameters
$name : string
$path : string = '/'
$domain : string = 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(mixed $key, mixed $values[, mixed $replace = true ]) : mixed
Parameters
$key : mixed

The key

$values : mixed

The value or an array of values

$replace : mixed = true

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

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

The value of the Cache-Control HTTP header

Return values
array<string|int, mixed>

An array representing the attribute values

Search results