class Request implements IRequest

HttpRequest provides access scheme for request sent via HTTP.

Properties

UrlScript read-only $url
array read-only $query
array read-only $post
array read-only $files
array read-only $cookies
string read-only $method
array read-only $headers
Url|null read-only $referer
bool read-only $secured
bool read-only $ajax
string|null read-only $remoteAddress
string|null read-only $remoteHost
string|null read-only $rawBody

Methods

__construct(UrlScript $url, $query = null, $post = null, $files = null, $cookies = null, $headers = null, $method = null, $remoteAddress = null, $remoteHost = null, $rawBodyCallback = null)

No description

getUrl()

Returns URL object.

mixed
getQuery($key = null, $default = null)

Returns variable provided to the script via URL query ($_GET).

mixed
getPost($key = null, $default = null)

Returns variable provided to the script via POST method ($_POST).

FileUpload|array|null
getFile($key)

Returns uploaded file.

array
getFiles()

Returns uploaded files.

mixed
getCookie($key, $default = null)

Returns variable provided to the script via HTTP cookies.

array
getCookies()

Returns variables provided to the script via HTTP cookies.

string
getMethod()

Returns HTTP request method (GET, POST, HEAD, PUT, ...). The method is case-sensitive.

bool
isMethod($method)

Checks if the request method is the given one.

isPost() deprecated

No description

string|null
getHeader($header, $default = null)

Return the value of the HTTP header. Pass the header name as the plain, HTTP-specified header name (e.g. 'Accept-Encoding').

array
getHeaders()

Returns all HTTP headers.

Url|null
getReferer()

Returns referrer.

bool
isSecured()

Is the request sent via secure channel (https)?

bool
isSameSite()

Is the request sent from the same origin?

bool
isAjax()

Is AJAX request?

string|null
getRemoteAddress()

Returns the IP address of the remote client.

string|null
getRemoteHost()

Returns the host of the remote client.

string|null
getRawBody()

Returns raw content of HTTP request body.

string|null
detectLanguage(array $langs)

Parse Accept-Language header and returns preferred language.

Details

at line 62
__construct(UrlScript $url, $query = null, $post = null, $files = null, $cookies = null, $headers = null, $method = null, $remoteAddress = null, $remoteHost = null, $rawBodyCallback = null)

No description

Parameters

UrlScript $url
$query
$post
$files
$cookies
$headers
$method
$remoteAddress
$remoteHost
$rawBodyCallback

at line 85
UrlScript getUrl()

Returns URL object.

Return Value

UrlScript

at line 101
mixed getQuery($key = null, $default = null)

Returns variable provided to the script via URL query ($_GET).

If no key is passed, returns the entire array.

Parameters

$key
$default

Return Value

mixed

at line 118
mixed getPost($key = null, $default = null)

Returns variable provided to the script via POST method ($_POST).

If no key is passed, returns the entire array.

Parameters

$key
$default

Return Value

mixed

at line 137
FileUpload|array|null getFile($key)

Returns uploaded file.

Parameters

$key

Return Value

FileUpload|array|null

at line 147
array getFiles()

Returns uploaded files.

Return Value

array

at line 159
mixed getCookie($key, $default = null)

Returns variable provided to the script via HTTP cookies.

Parameters

$key
$default

Return Value

mixed

at line 169
array getCookies()

Returns variables provided to the script via HTTP cookies.

Return Value

array

at line 182
string getMethod()

Returns HTTP request method (GET, POST, HEAD, PUT, ...). The method is case-sensitive.

Return Value

string

at line 193
bool isMethod($method)

Checks if the request method is the given one.

Parameters

$method

Return Value

bool

at line 202
isPost() deprecated

deprecated

No description

at line 216
string|null getHeader($header, $default = null)

Return the value of the HTTP header. Pass the header name as the plain, HTTP-specified header name (e.g. 'Accept-Encoding').

Parameters

$header
$default

Return Value

string|null

at line 227
array getHeaders()

Returns all HTTP headers.

Return Value

array

at line 237
Url|null getReferer()

Returns referrer.

Return Value

Url|null

at line 247
bool isSecured()

Is the request sent via secure channel (https)?

Return Value

bool

at line 257
bool isSameSite()

Is the request sent from the same origin?

Return Value

bool

at line 267
bool isAjax()

Is AJAX request?

Return Value

bool

at line 277
string|null getRemoteAddress()

Returns the IP address of the remote client.

Return Value

string|null

at line 287
string|null getRemoteHost()

Returns the host of the remote client.

Return Value

string|null

at line 300
string|null getRawBody()

Returns raw content of HTTP request body.

Return Value

string|null

at line 311
string|null detectLanguage(array $langs)

Parse Accept-Language header and returns preferred language.

Parameters

array $langs

Return Value

string|null

Traits

SmartObject