Skip to content

Request

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

public static string[] $requestTypes
  • This property is static.

requestTypesPost

Post request-types.

public static string[] $requestTypesPost
  • This property is static.

data

Additional data.

private array $data

httpHeaders

Server headers.

protected array $httpHeaders

contentType

Request ContentType

protected string $contentType

host

Request host.

protected ?string $host

url

Current request url.

protected ?\Qubus\Http\Url $url

method

Request method.

protected ?string $method

inputHandler

Input handler.

protected ?\Qubus\Http\Input\Handler $inputHandler

hasPendingRewrite

Defines if request has pending rewrite.

protected bool $hasPendingRewrite

rewriteUrl

Rewrite url.

protected ?string $rewriteUrl

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

public isSecure(): bool

getUrl

public getUrl(): \Qubus\Http\Url

getUrlCopy

Copy url object.

public getUrlCopy(): \Qubus\Http\Url

getHost

public getHost(): ?string

getAuthUser

Get http basic auth user.

public getAuthUser(): ?string

getAuthPassword

Get http basic auth password.

public getAuthPassword(): ?string

getHttpHeaders

Get all headers.

public getHttpHeaders(): array

getIp

Get ip address.

public getIp(bool $safeMode = false): string|null

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

public getRemoteAddr(): string|null

getReferer

Get referer.

public getReferer(): ?string

getUserAgent

Get user agent.

public getUserAgent(): ?string

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.

public getFirstHeader(array $headers, mixed|null $defaultValue = null): mixed|null

Parameters:

Parameter Type Description
$headers array
$defaultValue mixed|null

getContentType

Gets content type which request has been made.

public getContentType(): string|null

withContentType

Set request content-type

protected withContentType(string $contentType): $this

Parameters:

Parameter Type Description
$contentType string

handler

Get input class

public handler(): \Qubus\Http\Input\Handler

isFormatAccepted

Is format accepted

public isFormatAccepted(string $format): bool

Parameters:

Parameter Type Description
$format string

isAjax

Returns true if the request is made through Ajax

public isAjax(): bool

getBasicAuth

Gets auth info accepted by the browser/client.

public getBasicAuth(): array|null

getDigestAuth

Gets auth info accepted by the browser/client.

public getDigestAuth(): array

getClientAddress

Gets most possible client IPv4 Address.

public getClientAddress(bool $trustForwardedHeader = false): bool|string

Parameters:

Parameter Type Description
$trustForwardedHeader bool

getServerAddress

Gets active server address IP.

public getServerAddress(): string

getServerName

Gets active server name.

public getServerName(): string

getScheme

Gets HTTP schema (http/https).

public getScheme(): string

getServer

Gets variable from $_SERVER super global.

public getServer(string $name): ?string

Parameters:

Parameter Type Description
$name string

hasServer

Checks whether $_SERVER super global has certain index.

final public hasServer(string $name): string
  • 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.

public isPostBack(): bool

getAcceptFormats

Get accept formats.

public getAcceptFormats(): array

setUrl

public setUrl(\Qubus\Http\Url $url): void

Parameters:

Parameter Type Description
$url \Qubus\Http\Url

setHost

public setHost(?string $host): void

Parameters:

Parameter Type Description
$host ?string

setMethod

public setMethod(string $method): void

Parameters:

Parameter Type Description
$method string

getRewriteUrl

Get rewrite url.

public getRewriteUrl(): ?string

setRewriteUrl

Set rewrite url.

public setRewriteUrl(string $rewriteUrl): $this

Parameters:

Parameter Type Description
$rewriteUrl string

isMethod

Does this request use a given method?

public isMethod(string $method): bool

Parameters:

Parameter Type Description
$method string HTTP method.

isDelete

Checks whether HTTP method is DELETE.

public isDelete(): bool

isGet

Checks whether HTTP method is GET.

public isGet(): bool

isHead

Checks whether HTTP method is HEAD.

public isHead(): bool

isOptions

Checks whether HTTP method is OPTIONS.

public isOptions(): bool

isPatch

Checks whether HTTP method is PATCH.

public isPatch(): bool

isPost

Checks whether HTTP method is POST.

public isPost(): bool

isPut

Checks whether HTTP method is PUT.

public isPut(): bool

isConnect

Checks whether HTTP method is CONNECT.

public isConnect(): bool

isTrace

Checks whether HTTP method is TRACE.

public isTrace(): bool

isValidHttpMethod

Checks if a method is a valid HTTP method.

public isValidHttpMethod(string $method): bool

Parameters:

Parameter Type Description
$method string

getServerArray

protected getServerArray(): array

__isset

public __isset(string $name): mixed

Parameters:

Parameter Type Description
$name string

__set

public __set(string $name, ?string $value = null): mixed

Parameters:

Parameter Type Description
$name string
$value ?string

__get

public __get(string $name): mixed

Parameters:

Parameter Type Description
$name string


Automatically generated on 2025-10-13