Request
- Full name:
\Qubus\Http\Request
- Parent class:
Request
- This class is marked as final and can't be subclassed
- This class implements:
\Psr\Http\Message\RequestInterface
- This class is a Final class
Constants
Constant | Visibility | Type | Value |
---|---|---|---|
REQUEST_TYPE_GET | public | 'get' | |
REQUEST_TYPE_POST | public | 'post' | |
REQUEST_TYPE_PUT | public | 'put' | |
REQUEST_TYPE_PATCH | public | 'patch' | |
REQUEST_TYPE_OPTIONS | public | 'options' | |
REQUEST_TYPE_DELETE | public | 'delete' | |
REQUEST_TYPE_HEAD | public | 'head' | |
CONTENT_TYPE_JSON | public | 'application/json' | |
CONTENT_TYPE_FORM_DATA | public | 'multipart/form-data' | |
CONTENT_TYPE_X_FORM_ENCODED | public | 'application/x-www-form-urlencoded' | |
FORCE_METHOD_KEY | public | '_method' |
Properties
requestTypes
All request-types
- This property is static.
requestTypesPost
Post request-types.
- This property is static.
data
Additional data.
httpHeaders
Server headers.
contentType
Request ContentType
host
Request host.
url
Current request url.
method
Request method.
inputHandler
Input handler.
hasPendingRewrite
Defines if request has pending rewrite.
rewriteUrl
Rewrite url.
Methods
__construct
public __construct(null|string|\Psr\Http\Message\UriInterface $uri = null, null|string $method = null, string|resource|\Psr\Http\Message\StreamInterface $body = 'php://temp', array $headers = []): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$uri | null|string|\Psr\Http\Message\UriInterface | URI for the request, if any. |
$method | null|string | HTTP method for the request, if any. |
$body | string|resource|\Psr\Http\Message\StreamInterface | Message body, if any. |
$headers | array | Headers for the message, if any. |
Throws:
For any invalid value.
isSecure
getUrl
getUrlCopy
Copy url object.
getHost
getAuthUser
Get http basic auth user.
getAuthPassword
Get http basic auth password.
getHttpHeaders
Get all headers.
getIp
Get ip address.
If $safeMode is false, this function will detect Proxys. But the user can edit this header to whatever he wants! https://stackoverflow.com/questions/3003145/how-to-get-the-client-ip-address-in-php#comment-25086804
Parameters:
Parameter | Type | Description |
---|---|---|
$safeMode | bool | When enabled, only safe non-spoofable headers will be returned. Note this can cause issues when using proxy. |
getRemoteAddr
Get remote address/ip
getReferer
Get referer.
getUserAgent
Get user agent.
getHttpHeader
Get header value by name
public getHttpHeader(string $name, string|mixed|null $defaultValue = null, bool $tryParse = true): ?string
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string | Name of the header. |
$defaultValue | string|mixed|null | Value to be returned if header is not found. |
$tryParse | bool | When enabled the method will try to find the header from both client (http) and server-side variants, if the header is not found. |
getFirstHeader
Will try to find first header from list of headers.
Parameters:
Parameter | Type | Description |
---|---|---|
$headers | array | |
$defaultValue | mixed|null |
getContentType
Gets content type which request has been made.
withContentType
Set request content-type
Parameters:
Parameter | Type | Description |
---|---|---|
$contentType | string |
handler
Get input class
isFormatAccepted
Is format accepted
Parameters:
Parameter | Type | Description |
---|---|---|
$format | string |
isAjax
Returns true if the request is made through Ajax
getBasicAuth
Gets auth info accepted by the browser/client.
getDigestAuth
Gets auth info accepted by the browser/client.
getClientAddress
Gets most possible client IPv4 Address.
Parameters:
Parameter | Type | Description |
---|---|---|
$trustForwardedHeader | bool |
getServerAddress
Gets active server address IP.
getServerName
Gets active server name.
getScheme
Gets HTTP schema (http/https).
getServer
Gets variable from $_SERVER super global.
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string |
hasServer
Checks whether $_SERVER super global has certain index.
- This method is final.
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string |
isPostBack
Returns true when request-method is type that could contain data in the page body.
getAcceptFormats
Get accept formats.
setUrl
Parameters:
Parameter | Type | Description |
---|---|---|
$url | \Qubus\Http\Url |
setHost
Parameters:
Parameter | Type | Description |
---|---|---|
$host | ?string |
setMethod
Parameters:
Parameter | Type | Description |
---|---|---|
$method | string |
getRewriteUrl
Get rewrite url.
setRewriteUrl
Set rewrite url.
Parameters:
Parameter | Type | Description |
---|---|---|
$rewriteUrl | string |
isMethod
Does this request use a given method?
Parameters:
Parameter | Type | Description |
---|---|---|
$method | string | HTTP method. |
isDelete
Checks whether HTTP method is DELETE.
isGet
Checks whether HTTP method is GET.
isHead
Checks whether HTTP method is HEAD.
isOptions
Checks whether HTTP method is OPTIONS.
isPatch
Checks whether HTTP method is PATCH.
isPost
Checks whether HTTP method is POST.
isPut
Checks whether HTTP method is PUT.
isConnect
Checks whether HTTP method is CONNECT.
isTrace
Checks whether HTTP method is TRACE.
isValidHttpMethod
Checks if a method is a valid HTTP method.
Parameters:
Parameter | Type | Description |
---|---|---|
$method | string |
getServerArray
__isset
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string |
__set
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string | |
$value | ?string |
__get
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string |
Automatically generated on 2025-10-13