class Request extends AbstractMessage implements RequestInterface

Class Request

Methods

string|array|null
getHeader(string $name, string|boolean $glue = "\r\n")

Returns the value of a header.

array
getHeaderAttributes(string $name)

Returns a header's attributes.

string|null
getHeaderAttribute(string $header, string $attribute)

Returns the value of a particular header attribute.

toDomDocument()

Returns the current message as a DOMDocument.

setHeaders(array $headers)

Sets all headers on the current message.

addHeader(string $header)

Adds a header to this message.

addHeaders(array $headers)

Adds a set of headers to this message.

array
getHeaders()

Merges cookie headers on the way out.

setContent(string $content)

Sets the content of the message.

string
getContent()

Returns the content of the message.

string
__toString()

Returns a string representation of the current request.

flattenHeaders(array $headers)

No description

__construct(string $method = self::METHOD_GET, string $resource = '/', string $host = null)

Constructor.

setMethod(string $method)

Sets the HTTP method of the current request.

string
getMethod()

Returns the HTTP method of the current request.

setResource(string $resource)

Sets the resource for the current request.

string
getResource()

Returns the resource portion of the request line.

setHost(string $host)

Sets the host for the current request.

string|null
getHost()

Returns the value of the host header.

setProtocolVersion($protocolVersion)

No description

float
getProtocolVersion()

Returns the protocol version of the current request.

string
getUrl()

A convenience method for getting the full URL of the current request.

fromUrl(Url|string $url)

A convenience method for populating the current request from a URL.

Boolean
isSecure()

Returns true if the current request is secure.

Details

in AbstractMessage at line 22
string|array|null getHeader(string $name, string|boolean $glue = "\r\n")

Returns the value of a header.

Parameters

string $name A header name
string|boolean $glue Glue for implode, or false to return an array

Return Value

string|array|null The header value(s)

in AbstractMessage at line 47
array getHeaderAttributes(string $name)

Returns a header's attributes.

Parameters

string $name A header name

Return Value

array An associative array of attributes

in AbstractMessage at line 74
string|null getHeaderAttribute(string $header, string $attribute)

Returns the value of a particular header attribute.

Parameters

string $header A header name
string $attribute An attribute name

Return Value

string|null The value of the attribute or null if it isn't set

in AbstractMessage at line 88
DOMDocument toDomDocument()

Returns the current message as a DOMDocument.

Return Value

DOMDocument

at line 33
setHeaders(array $headers)

Sets all headers on the current message.

Headers can be complete ["Header: value"] pairs or an associative array ["Header" => "value"]

Parameters

array $headers An array of header lines

at line 42
addHeader(string $header)

Adds a header to this message.

Parameters

string $header A header line

in AbstractMessage at line 114
addHeaders(array $headers)

Adds a set of headers to this message.

Headers can be complete ["Header: value"] pairs or an associative array ["Header" => "value"]

Parameters

array $headers Headers

at line 132
array getHeaders()

Merges cookie headers on the way out.

Return Value

array An array of header lines (integer indexes, e.g. ["Header: value"])

in AbstractMessage at line 124
setContent(string $content)

Sets the content of the message.

Parameters

string $content The message content

in AbstractMessage at line 129
string getContent()

Returns the content of the message.

Return Value

string The message content

at line 142
string __toString()

Returns a string representation of the current request.

Return Value

string The message

in AbstractMessage at line 145
protected flattenHeaders(array $headers)

Parameters

array $headers

at line 26
__construct(string $method = self::METHOD_GET, string $resource = '/', string $host = null)

Constructor.

Parameters

string $method
string $resource
string $host

at line 55
setMethod(string $method)

Sets the HTTP method of the current request.

Parameters

string $method The request method

at line 60
string getMethod()

Returns the HTTP method of the current request.

Return Value

string An HTTP method

at line 65
setResource(string $resource)

Sets the resource for the current request.

Parameters

string $resource The resource being requested

at line 70
string getResource()

Returns the resource portion of the request line.

Return Value

string The resource requested

at line 75
setHost(string $host)

Sets the host for the current request.

Parameters

string $host The host

at line 80
string|null getHost()

Returns the value of the host header.

Return Value

string|null The host

at line 85
setProtocolVersion($protocolVersion)

Parameters

$protocolVersion

at line 90
float getProtocolVersion()

Returns the protocol version of the current request.

Return Value

float The protocol version

at line 100
string getUrl()

A convenience method for getting the full URL of the current request.

Return Value

string

at line 110
fromUrl(Url|string $url)

A convenience method for populating the current request from a URL.

Parameters

Url|string $url An URL

at line 124
Boolean isSecure()

Returns true if the current request is secure.

Return Value

Boolean True if the request is secure