PHP Класс lithium\net\http\Response

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

Открытые свойства

Свойство Тип Описание
$cookies array Cookies are stored as arrays of $name => $value where $value is an associative array or an array of associative arrays which contain at minimum a value key and optionally, expire, path, domain, secure, and/or httponly keys corresponding to the parameters of PHP setcookie().
$encoding string Character encoding.
$status array Status code and message.

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

Свойство Тип Описание
$_statuses array Status codes.

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

Метод Описание
__construct ( array $config = [] ) : void Constructor. Adds config values to the public properties when a new object is created.
__toString ( ) : string Return the response as a string.
body ( mixed $data = null, array $options = [] ) : array Add data to or compile and return the HTTP message body, optionally decoding its parts according to content type.
cookies ( string $key = null, string $value = null ) : mixed Add a cookie to header output, or return a single cookie or full cookie list.
digest ( ) : array Looks at the WWW-Authenticate. Will return array of key/values if digest.
status ( string $key = null, string $status = null ) : string Set and get the status for the response.

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

Метод Описание
_cookies ( ) : array Render Set-Cookie headers, urlencoding invalid characters.
_httpChunkedDecode ( string $body ) : string Decodes content bodies transferred with HTTP chunked encoding.
_parseCookies ( array $headers ) Parse Set-Cookie headers.
_parseMessage ( string $body ) : After Accepts an entire HTTP message including headers and body, and parses it into a message body an array of headers, and the HTTP status.

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

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

Constructor. Adds config values to the public properties when a new object is created.
См. также: lithium\net\http\Message::__construct()
См. также: lithium\net\Message::__construct()
public __construct ( array $config = [] ) : void
$config array The available configuration options are the following. Further options are inherited from the parent classes. - `'message'` _string_: Defaults to `null`. - `'status'` _mixed_: Defaults to `null`. - `'type'` _string_: Defaults to `null`. - `'cookies'` _array_: Defaults to `array()`.
Результат void

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

Return the response as a string.
public __toString ( ) : string
Результат string

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

NOTE: Technically '+' is a valid character, but many browsers erroneously convert these to spaces, so we must escape this too.
protected _cookies ( ) : array
Результат array Array of `Set-Cookie` headers or `null` if no cookies to set.

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

Decodes content bodies transferred with HTTP chunked encoding.
protected _httpChunkedDecode ( string $body ) : string
$body string A chunked HTTP message body.
Результат string Returns the value of `$body` with chunks decoded, but only if the value of the `Transfer-Encoding` header is set to `'chunked'`. Otherwise, returns `$body` unmodified.

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

Parse Set-Cookie headers.
protected _parseCookies ( array $headers )
$headers array Array of `Set-Cookie` headers or `null` if no cookies to set.

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

Accepts an entire HTTP message including headers and body, and parses it into a message body an array of headers, and the HTTP status.
protected _parseMessage ( string $body ) : After
$body string The full body of the message.
Результат After parsing out other message components, returns just the message body.

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

Add data to or compile and return the HTTP message body, optionally decoding its parts according to content type.
См. также: lithium\net\Message::body()
См. также: lithium\net\http\Message::_decode()
public body ( mixed $data = null, array $options = [] ) : array
$data mixed
$options array - `'buffer'` _integer_: split the body string - `'encode'` _boolean_: encode the body based on the content type - `'decode'` _boolean_: decode the body based on the content type
Результат array

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

This function's parameters are designed to be analogous to setcookie(). Function parameters expire, path, domain, secure, and httponly may be passed in as an associative array alongside value inside $value. NOTE: Cookies values are expected to be scalar. This function will not serialize cookie values. If you wish to store a non-scalar value, you must serialize the data first. NOTE: Cookie values are stored as an associative array containing at minimum a value key. Cookies which have been set multiple times do not overwrite each other. Rather they are stored as an array of associative arrays.
public cookies ( string $key = null, string $value = null ) : mixed
$key string
$value string
Результат mixed

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

Looks at the WWW-Authenticate. Will return array of key/values if digest.
public digest ( ) : array
Результат array

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

Set and get the status for the response.
public status ( string $key = null, string $status = null ) : string
$key string Optional. Set to `'code'` or `'message'` to return just the code or message of the status, otherwise returns the full status header.
$status string The code or message of the status you wish to set.
Результат string Returns the full HTTP status, with version, code and message or dending on $key just the code or message.

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

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

Status codes.
protected array $_statuses
Результат array

$cookies публичное свойство

Cookies are stored as arrays of $name => $value where $value is an associative array or an array of associative arrays which contain at minimum a value key and optionally, expire, path, domain, secure, and/or httponly keys corresponding to the parameters of PHP setcookie().
См. также: lithium\net\http\Response::cookies()
public array $cookies
Результат array

$encoding публичное свойство

Character encoding.
public string $encoding
Результат string

$status публичное свойство

Status code and message.
public array $status
Результат array