Constants

COOKIES_FLAT

COOKIES_FLAT

Tags

None found

COOKIES_ARRAY

COOKIES_ARRAY

Tags

None found

DISPOSITION_ATTACHMENT

DISPOSITION_ATTACHMENT

Tags

None found

DISPOSITION_INLINE

DISPOSITION_INLINE

Tags

None found

Properties

$headers

$headers : 

Type

Inherited from
SymfonyComponentHttpFoundationHeaderBag

Tags

None found

$cacheControl

$cacheControl : 

Type

Inherited from
SymfonyComponentHttpFoundationHeaderBag

Tags

None found

$computedCacheControl

$computedCacheControl : array

Type

array

Tags

None found

$cookies

$cookies : array

Type

array

Tags

None found

$headerNames

$headerNames : array

Type

array

Tags

None found

Methods

__construct()

__construct(array  $headers = array()) 

Constructor.

Parameters

array $headers

An array of HTTP headers

Tags

api

__toString()

__toString() : string

Returns the headers as a string.

Returns

string —

The headers

Tags

None found

all()

all() : array

Returns the headers.

Returns

array —

An array of headers

keys()

keys() : array

Returns the parameter keys.

Returns

array —

An array of parameter keys

replace()

replace(array  $headers = array()) 

Replaces the current HTTP headers by a new set.

Parameters

array $headers

An array of HTTP headers

Tags

api

add()

add(array  $headers) 

Adds new headers the current HTTP headers set.

Parameters

array $headers

An array of HTTP headers

get()

get(string  $key, mixed  $default = null, Boolean  $first = true) : string|array

Returns a header value by name.

Parameters

string $key

The header name

mixed $default

The default value

Boolean $first

Whether to return the first value or all header values

Returns

string|array —

The first header value if $first is true, an array of values otherwise

set()

set(string  $key, string|array  $values, Boolean  $replace = true) 

Sets a header by name.

Parameters

string $key

The key

string|array $values

The value or an array of values

Boolean $replace

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

Tags

api

has()

has(string  $key) : Boolean

Returns true if the HTTP header is defined.

Parameters

string $key

The HTTP header

Returns

Boolean —

true if the parameter exists, false otherwise

contains()

contains(string  $key, string  $value) : Boolean

Returns true if the given HTTP header contains the given value.

Parameters

string $key

The HTTP header name

string $value

The HTTP value

Returns

Boolean —

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

remove()

remove(string  $key) 

Removes a header.

Parameters

string $key

The HTTP header name

Tags

api

getDate()

getDate(string  $key, \DateTime  $default = null) : null|\DateTime

Returns the HTTP header value converted to a date.

Parameters

string $key

The parameter key

DateTime $default

The default value

Throws

RuntimeException

When the HTTP header is not parseable

Returns

null|DateTime —

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

addCacheControlDirective()

addCacheControlDirective(  $key,   $value = true) 

Parameters

$key
$value

Inherited from
SymfonyComponentHttpFoundationHeaderBag

Tags

None found

hasCacheControlDirective()

hasCacheControlDirective(  $key) 

Parameters

$key

Tags

None found

getCacheControlDirective()

getCacheControlDirective(  $key) 

Parameters

$key

Tags

None found

removeCacheControlDirective()

removeCacheControlDirective(  $key) 

Parameters

$key

Inherited from
SymfonyComponentHttpFoundationHeaderBag

Tags

None found

getIterator()

getIterator() : \ArrayIterator

Returns an iterator for headers.

Returns

ArrayIterator —

An ArrayIterator instance

Inherited from
SymfonyComponentHttpFoundationHeaderBag

Tags

None found

count()

count() : integer

Returns the number of headers.

Returns

integer —

The number of headers

Inherited from
SymfonyComponentHttpFoundationHeaderBag

Tags

None found

allPreserveCase()

allPreserveCase() : array

Returns the headers, with original capitalizations.

Returns

array —

An array of headers

Tags

None found

setCookie()

setCookie(\Symfony\Component\HttpFoundation\Cookie  $cookie) 

Sets a cookie.

Parameters

SymfonyComponentHttpFoundationCookie $cookie

Tags

api

removeCookie()

removeCookie(string  $name, string  $path = '/', string  $domain = null) 

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

Parameters

string $name
string $path
string $domain

Tags

api

getCookies()

getCookies(string $format = self::COOKIES_FLAT) : array

Returns an array with all cookies

Parameters

string $format

Throws

InvalidArgumentException

When the $format is invalid

Returns

array

Tags

api

clearCookie()

clearCookie(string  $name, string  $path = '/', string  $domain = null) 

Clears a cookie in the browser

Parameters

string $name
string $path
string $domain

Tags

api

makeDisposition()

makeDisposition(string  $disposition, string  $filename, string  $filenameFallback = '') : string

Generates a HTTP Content-Disposition field-value.

Parameters

string $disposition

One of "inline" or "attachment"

string $filename

A unicode string

string $filenameFallback

A string containing only ASCII characters that is semantically equivalent to $filename. If the filename is already ASCII, it can be omitted, or just copied from $filename

Throws

InvalidArgumentException

Returns

string —

A string suitable for use as a Content-Disposition field-value.

See also
6266

Tags

None found

getCacheControlHeader()

getCacheControlHeader() 

Inherited from
SymfonyComponentHttpFoundationHeaderBag

Tags

None found

parseCacheControl()

parseCacheControl(string  $header) : array

Parses a Cache-Control HTTP header.

Parameters

string $header

The value of the Cache-Control HTTP header

Returns

array —

An array representing the attribute values

Inherited from
SymfonyComponentHttpFoundationHeaderBag

Tags

None found

computeCacheControlValue()

computeCacheControlValue() : string

Returns the calculated value of the cache-control header.

This considers several other headers and calculates or modifies the cache-control header to a sensible, conservative value.

Returns

string

Tags

None found