Documentation

Request
in package

Class for handling web requests.

Table of Contents

Constants

Boundary  = '---------------------------'
Separator
BoundaryEnd  = '--'
Ending

Properties

$async  : bool
Asynchronous indicator
$boundary  : string|null
Separator
$contentType  : string|null
Content Type
$cookieFile  : string
Cookie file
$cookies  : array<string|int, mixed>
Cookies
$credentials  : Credentials|null
Logins and passwords
$encryption  : string
Encryption
$headers  : array<string|int, mixed>|null
Headers
$method  : string
Method
$postData  : Data|string|null
Data
$referer  : string
Referer
$sshSecurityLevel  : int|null
SSH security level
$sslVerify  : bool
Check SSL certificate
$target  : string
Target address
$timeout  : int
Request timeout
$timeout_ms  : int|null
Timeout in milliseconds
$useragent  : string
UserAgent

Methods

__construct()  : mixed
Constructor
Execute()  : Result
Executes the request.
Get()  : Result
Sends a GET request.
__checkWebRequest()  : bool
Checks if the curl module loaded
_createMultipartRequestBody()  : string|array<string|int, mixed>
Creates request data of type Multipart/Formdata.
_joinPostData()  : string|array<string|int, mixed>
Constructs the POST data.
_parseBody()  : array<string|int, string|array<string|int, mixed>>
Processes the result received from cURL and extracts headers.

Constants

Boundary

Separator

public mixed Boundary = '---------------------------'

BoundaryEnd

Ending

public mixed BoundaryEnd = '--'

Properties

$async

Asynchronous indicator

public bool $async = false

$boundary

Separator

public string|null $boundary = null

$contentType

Content Type

public string|null $contentType = null

$cookieFile

Cookie file

public string $cookieFile = ''

$cookies

Cookies

public array<string|int, mixed> $cookies = []

$encryption

Encryption

public string $encryption = \Colibri\IO\Request\Encryption::UrlEncoded

$headers

Headers

public array<string|int, mixed>|null $headers = null

$method

Method

public string $method = \Colibri\IO\Request\Type::Get

$referer

Referer

public string $referer = ''

$sshSecurityLevel

SSH security level

public int|null $sshSecurityLevel = null

$sslVerify

Check SSL certificate

public bool $sslVerify = true

$target

Target address

public string $target

$timeout

Request timeout

public int $timeout = 60

$timeout_ms

Timeout in milliseconds

public int|null $timeout_ms = null

$useragent

UserAgent

public string $useragent = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 Safari/534.30'

Methods

__construct()

Constructor

public __construct(string $target[, string $method = Type::Get ][, string $encryption = Encryption::UrlEncoded ][, Data|string|null $postData = null ][, string $boundary = '' ]) : mixed
Parameters
$target : string
$method : string = Type::Get
$encryption : string = Encryption::UrlEncoded
$postData : Data|string|null = null
$boundary : string = ''
Tags
throws
Exception

Execute()

Executes the request.

public Execute([mixed $postData = null ]) : Result
Parameters
$postData : mixed = null

The data to be posted

Return values
Result

The result of the request

Get()

Sends a GET request.

public static Get(string $target[, int $timeout = 0 ][, bool $sslVerify = true ][, array<string|int, mixed> $headers = [] ]) : Result
Parameters
$target : string

The target URL

$timeout : int = 0

The timeout for the request (default is 0)

$sslVerify : bool = true

Whether to verify SSL certificates (default is true)

$headers : array<string|int, mixed> = []

Additional headers to be included in the request (default is an empty array)

Return values
Result

The result of the request

__checkWebRequest()

Checks if the curl module loaded

private static __checkWebRequest() : bool
Return values
bool

_createMultipartRequestBody()

Creates request data of type Multipart/Formdata.

private _createMultipartRequestBody(string $boundary, mixed $files) : string|array<string|int, mixed>
Parameters
$boundary : string

The boundary delimiter.

$files : mixed

The data.

Return values
string|array<string|int, mixed>

_joinPostData()

Constructs the POST data.

private _joinPostData() : string|array<string|int, mixed>
Return values
string|array<string|int, mixed>

_parseBody()

Processes the result received from cURL and extracts headers.

private _parseBody(string $body[, int $header_size = 0 ]) : array<string|int, string|array<string|int, mixed>>
Parameters
$body : string

The result body along with headers

$header_size : int = 0

The size of the headers

Return values
array<string|int, string|array<string|int, mixed>>

An array containing the body and headers


        
On this page

Search results