PHP Класс Neos\Flow\Http\Headers

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$cacheDirectives array
$cookies array
$fields array

Открытые методы

Метод Описание
__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

Защищенные методы

Метод Описание
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.

Описание методов

__construct() публичный Метод

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() публичный статический Метод

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"
Результат Headers

eatCookie() публичный Метод

Although not 100% semantically correct, an alias for removeCookie()
public eatCookie ( string $name ) : void
$name string Name of the cookie to eat
Результат void

get() публичный Метод

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.
Результат 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() публичный Метод

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
Результат array

getCacheControlDirective() публичный Метод

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"
Результат mixed

getCacheControlHeader() защищенный Метод

Renders and returns a Cache-Control header, based on the previously set cache control directives.
См. также: get()
protected getCacheControlHeader ( ) : string
Результат string Either the value of the header or NULL if it shall be omitted

getCookie() публичный Метод

Returns a cookie specified by the given name
public getCookie ( string $name ) : Cookie
$name string Name of the cookie
Результат Cookie The cookie or NULL if no such cookie exists

getCookies() публичный Метод

Returns all cookies
public getCookies ( ) : array
Результат array

has() публичный Метод

Checks if the specified HTTP header exists
public has ( string $name ) : boolean
$name string Name of the header
Результат boolean

hasCookie() публичный Метод

Checks if the specified cookie exists
public hasCookie ( string $name ) : boolean
$name string Name of the cookie
Результат boolean

remove() публичный Метод

Removes the specified header field
public remove ( string $name ) : void
$name string Name of the field
Результат void

removeCacheControlDirective() публичный Метод

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"
Результат void

removeCookie() публичный Метод

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
Результат void

set() публичный Метод

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.
Результат void

setCacheControlDirective() публичный Метод

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
Результат void

setCacheControlDirectivesFromRawHeader() защищенный Метод

Internally sets the cache directives correctly by parsing the given Cache-Control field value.
См. также: set()
protected setCacheControlDirectivesFromRawHeader ( string $rawFieldValue ) : void
$rawFieldValue string The value of a specification compliant Cache-Control header
Результат void

setCookie() публичный Метод

Sets a cookie
public setCookie ( Cookie $cookie ) : void
$cookie Cookie
Результат void

setCookiesFromRawHeader() защищенный Метод

Internally sets cookie objects based on the Cookie header field value.
См. также: set()
protected setCookiesFromRawHeader ( string $rawFieldValue ) : void
$rawFieldValue string The value of a specification compliant Cookie header
Результат void

Описание свойств

$cacheDirectives защищенное свойство

protected array $cacheDirectives
Результат array

$cookies защищенное свойство

protected array $cookies
Результат array

$fields защищенное свойство

protected array $fields
Результат array