PHP Class lithium\net\http\Response

Inheritance: extends Message
Afficher le fichier Open project: unionofrad/lithium Class Usage Examples

Méthodes publiques

Свойство Type Description
$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 Properties

Свойство Type Description
$_statuses array Status codes.

Méthodes publiques

Méthode Description
__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.

Méthodes protégées

Méthode Description
_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.

Method Details

__construct() public méthode

Constructor. Adds config values to the public properties when a new object is created.
See also: lithium\net\http\Message::__construct()
See also: 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()`.
Résultat void

__toString() public méthode

Return the response as a string.
public __toString ( ) : string
Résultat string

_cookies() protected méthode

NOTE: Technically '+' is a valid character, but many browsers erroneously convert these to spaces, so we must escape this too.
protected _cookies ( ) : array
Résultat array Array of `Set-Cookie` headers or `null` if no cookies to set.

_httpChunkedDecode() protected méthode

Decodes content bodies transferred with HTTP chunked encoding.
protected _httpChunkedDecode ( string $body ) : string
$body string A chunked HTTP message body.
Résultat 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() protected méthode

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

_parseMessage() protected méthode

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.
Résultat After parsing out other message components, returns just the message body.

body() public méthode

Add data to or compile and return the HTTP message body, optionally decoding its parts according to content type.
See also: lithium\net\Message::body()
See also: 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
Résultat array

cookies() public méthode

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
Résultat mixed

digest() public méthode

Looks at the WWW-Authenticate. Will return array of key/values if digest.
public digest ( ) : array
Résultat array

status() public méthode

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.
Résultat string Returns the full HTTP status, with version, code and message or dending on $key just the code or message.

Property Details

$_statuses protected_oe property

Status codes.
protected array $_statuses
Résultat array

$cookies public_oe property

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().
See also: lithium\net\http\Response::cookies()
public array $cookies
Résultat array

$encoding public_oe property

Character encoding.
public string $encoding
Résultat string

$status public_oe property

Status code and message.
public array $status
Résultat array