PHP Class Neos\Flow\Http\Headers

Afficher le fichier Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Свойство Type Description
$cacheDirectives array
$cookies array
$fields array

Méthodes publiques

Méthode Description
__construct ( array $fields = [] ) Constructs a new Headers object.
createFromServer ( array $server ) : Headers Creates a new Headers instance from the given $_SERVER-superglobal-like array.
eatCookie ( string $name ) : void Although not 100% semantically correct, an alias for removeCookie()
get ( string $name ) : array | string Returns the specified HTTP header
getAll ( ) : array Returns all header fields
getCacheControlDirective ( string $name ) : mixed Returns the value of the specified Cache-Control directive.
getCookie ( string $name ) : Cookie Returns a cookie specified by the given name
getCookies ( ) : array Returns all cookies
has ( string $name ) : boolean Checks if the specified HTTP header exists
hasCookie ( string $name ) : boolean Checks if the specified cookie exists
remove ( string $name ) : void Removes the specified header field
removeCacheControlDirective ( string $name ) : void Removes a special directive previously set for the Cache-Control header.
removeCookie ( string $name ) : void Removes the specified cookie if it exists
set ( string $name, array | string | DateTime $values, boolean $replaceExistingHeader = true ) : void Sets the specified HTTP header
setCacheControlDirective ( string $name, string $value = null ) : void Sets a special directive for use in the Cache-Control header, according to RFC 2616 / 14.9
setCookie ( Cookie $cookie ) : void Sets a cookie

Méthodes protégées

Méthode Description
getCacheControlHeader ( ) : string Renders and returns a Cache-Control header, based on the previously set cache control directives.
setCacheControlDirectivesFromRawHeader ( string $rawFieldValue ) : void Internally sets the cache directives correctly by parsing the given Cache-Control field value.
setCookiesFromRawHeader ( string $rawFieldValue ) : void Internally sets cookie objects based on the Cookie header field value.

Method Details

__construct() public méthode

Constructs a new Headers object.
public __construct ( array $fields = [] )
$fields array Field names and their values (either as single value or array of values)

createFromServer() public static méthode

Creates a new Headers instance from the given $_SERVER-superglobal-like array.
public static createFromServer ( array $server ) : Headers
$server array An array similar or equal to $_SERVER, containing headers in the form of "HTTP_FOO_BAR"
Résultat Headers

eatCookie() public méthode

Although not 100% semantically correct, an alias for removeCookie()
public eatCookie ( string $name ) : void
$name string Name of the cookie to eat
Résultat void

get() public méthode

Dates are returned as DateTime objects with the timezone set to GMT.
public get ( string $name ) : array | string
$name string Name of the header, for example "Location", "Content-Description" etc.
Résultat array | string An array of field values if multiple headers of that name exist, a string value if only one value exists and NULL if there is no such header.

getAll() public méthode

Note that even for those header fields which exist only one time, the value is returned as an array (with a single item).
public getAll ( ) : array
Résultat array

getCacheControlDirective() public méthode

If the cache directive is not present, NULL is returned. If the specified directive is present but contains no value, this method returns TRUE. Finally, if the directive is present and does contain a value, the value is returned.
public getCacheControlDirective ( string $name ) : mixed
$name string Name of the cache directive, for example "max-age"
Résultat mixed

getCacheControlHeader() protected méthode

Renders and returns a Cache-Control header, based on the previously set cache control directives.
See also: get()
protected getCacheControlHeader ( ) : string
Résultat string Either the value of the header or NULL if it shall be omitted

getCookie() public méthode

Returns a cookie specified by the given name
public getCookie ( string $name ) : Cookie
$name string Name of the cookie
Résultat Cookie The cookie or NULL if no such cookie exists

getCookies() public méthode

Returns all cookies
public getCookies ( ) : array
Résultat array

has() public méthode

Checks if the specified HTTP header exists
public has ( string $name ) : boolean
$name string Name of the header
Résultat boolean

hasCookie() public méthode

Checks if the specified cookie exists
public hasCookie ( string $name ) : boolean
$name string Name of the cookie
Résultat boolean

remove() public méthode

Removes the specified header field
public remove ( string $name ) : void
$name string Name of the field
Résultat void

removeCacheControlDirective() public méthode

Removes a special directive previously set for the Cache-Control header.
public removeCacheControlDirective ( string $name ) : void
$name string Name of the directive, for example "public"
Résultat void

removeCookie() public méthode

Note: This will remove the cookie object from this Headers container. If you intend to remove a cookie in the user agent (browser), you should call the cookie's expire() method and _not_ remove the cookie from the Headers container.
public removeCookie ( string $name ) : void
$name string Name of the cookie to remove
Résultat void

set() public méthode

DateTime objects will be converted to a string representation internally but will be returned as DateTime objects on calling get(). Please note that dates are normalized to GMT internally, so that get() will return the same point in time, but not necessarily in the same timezone, if it was not GMT previously. GMT is used synonymously with UTC as per RFC 2616 3.3.1.
public set ( string $name, array | string | DateTime $values, boolean $replaceExistingHeader = true ) : void
$name string Name of the header, for example "Location", "Content-Description" etc.
$values array | string | DateTime An array of values or a single value for the specified header field
$replaceExistingHeader boolean If a header with the same name should be replaced. Default is TRUE.
Résultat void

setCacheControlDirective() public méthode

Sets a special directive for use in the Cache-Control header, according to RFC 2616 / 14.9
public setCacheControlDirective ( string $name, string $value = null ) : void
$name string Name of the directive, for example "max-age"
$value string An optional value
Résultat void

setCacheControlDirectivesFromRawHeader() protected méthode

Internally sets the cache directives correctly by parsing the given Cache-Control field value.
See also: set()
protected setCacheControlDirectivesFromRawHeader ( string $rawFieldValue ) : void
$rawFieldValue string The value of a specification compliant Cache-Control header
Résultat void

setCookie() public méthode

Sets a cookie
public setCookie ( Cookie $cookie ) : void
$cookie Cookie
Résultat void

setCookiesFromRawHeader() protected méthode

Internally sets cookie objects based on the Cookie header field value.
See also: set()
protected setCookiesFromRawHeader ( string $rawFieldValue ) : void
$rawFieldValue string The value of a specification compliant Cookie header
Résultat void

Property Details

$cacheDirectives protected_oe property

protected array $cacheDirectives
Résultat array

$cookies protected_oe property

protected array $cookies
Résultat array

$fields protected_oe property

protected array $fields
Résultat array