PHP Class lithium\net\http\Request

Inheritance: extends Message
Show file Open project: unionofrad/lithium Class Usage Examples

Public Properties

Property Type Description
$auth mixed Any array with a 'nonce' attribute implies Digest authentication; all other non-empty values for imply Basic authentication.
$cookies array Cookies.
$method string The method of the request, typically one of the following: GET, POST, PUT, DELETE, OPTIONS, HEAD, TRACE or CONNECT.
$query array Key/value pairs found encoded in the URL after the '?'.

Protected Properties

Property Type Description
$_formats array An array of closures representing various formats this object can be exported to.

Public Methods

Method Description
__construct ( array $config = [] ) : void Constructor. Adds config values to the public properties when a new object is created.
__toString ( ) : string Magic method to convert object to string.
body ( mixed $data = null, array $options = [] ) : array Compile the HTTP message body, optionally encoding 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.
queryString ( array $params = [], string $format = null ) : string Get the full query string queryString.
to ( string $format, array $options = [] ) : mixed Converts the data in the record set to a different format, i.e. an array. Available options: array, URL, stream context configuration, or string.

Protected Methods

Method Description
_cookies ( ) : string Render Cookie header, urlencoding invalid characters.
_parseCookies ( string $header ) Parse Cookie header.

Method Details

__construct() public method

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. - `'method'` _string_: Defaults to `'GET'`. - `'path'` _string_: Defaults to `null`. - `'query'` _array_: Defaults to `array()`. - `'cookies'` _array_: Defaults to `array()`. - `'type'` _string_: Defaults to `null`. - `'auth'` _mixed_: Defaults to `null`. - `'proxy'` _string_: Defaults to `null`. - `'ignoreErrors'` _boolean_: Defaults to `true`. - `'followLocation'` _boolean_: Defaults to `true`.
return void

__toString() public method

Magic method to convert object to string.
public __toString ( ) : string
return string

_cookies() protected method

NOTE: Technically '+' is a valid character, but many browsers erroneously convert these to spaces, so we must escape this too.
protected _cookies ( ) : string
return string

_parseCookies() protected method

Parse Cookie header.
protected _parseCookies ( string $header )
$header string `Cookie` header.

body() public method

Compile the HTTP message body, optionally encoding its parts according to content type.
See also: lithium\net\http\Message::body()
See also: lithium\net\http\Message::_encode()
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
return array

cookies() public method

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.
public cookies ( string $key = null, string $value = null ) : mixed
$key string
$value string
return mixed

queryString() public method

Get the full query string queryString.
public queryString ( array $params = [], string $format = null ) : string
$params array
$format string
return string

to() public method

Converts the data in the record set to a different format, i.e. an array. Available options: array, URL, stream context configuration, or string.
See also: lithium\net\Message::to()
public to ( string $format, array $options = [] ) : mixed
$format string Format to convert to. Should be either `'url'`, which returns a string representation of the URL that this request points to, or `'context'`, which returns an array usable with PHP's `stream_context_create()` function. For more available formats, see the parent method, `lithium\net\Message::to()`.
$options array Allows overriding of specific portions of the URL, as follows. These options should only be specified if you intend to replace the values that are already in the `Request` object. - `'scheme'` _string_: The protocol scheme of the URL. - `'method'` _string_: If applicable, the HTTP method to use in the request. Mainly applies to the `'context'` format. - `'host'` _string_: The host name the request is pointing at. - `'port'` _string_: The host port, if any. - `'path'` _string_: The URL path. - `'query'` _mixed_: The query string of the URL as a string or array. - `'auth'` _string_: Authentication information. See the constructor for details. - `'content'` _string_: The body of the request. - `'headers'` _array_: The request headers. - `'version'` _string_: The HTTP version of the request, where applicable.
return mixed Varies; see the `$format` parameter for possible return values.

Property Details

$_formats protected property

An array of closures representing various formats this object can be exported to.
protected array $_formats
return array

$auth public property

Any array with a 'nonce' attribute implies Digest authentication; all other non-empty values for imply Basic authentication.
See also: lithium\net\http\Auth::encode()
public mixed $auth
return mixed

$cookies public property

Cookies.
public array $cookies
return array

$method public property

The method of the request, typically one of the following: GET, POST, PUT, DELETE, OPTIONS, HEAD, TRACE or CONNECT.
public string $method
return string

$query public property

Key/value pairs found encoded in the URL after the '?'.
public array $query
return array