Documentation

HTTP_client
in package

A HTTP client based on CURL.

Table of Contents

Properties

$curl  : mixed
A CURL instance.
$server  : mixed
Server URL.

Methods

__construct()  : mixed
The main class constructor.
__destruct()  : mixed
The main class destructor that closes the current CURL session.
get()  : HTTP
Make an HTTP GET request.
get_domain()  : Domain
Get domain name from the server URL.
get_port()  : Port
Get server port from the URL.
get_server()  : HTTP
Get the current server.
post()  : HTTP
Make an HTTP POST request.
post_file()  : mixed
Post a file to a server.
put()  : HTTP
Make an HTTP PUT request.
set_debug_mode()  : void
Set Curl debug mode to $value.
get_curl()  : mixed
Get Curl handle.
set_opt()  : void
Set Curl option.

Properties

Methods

__construct()

The main class constructor.

public __construct(string $server[, bool $is_debug_mode_enabled = false ]) : mixed
Parameters
$server : string

A Matrix server URL.

$is_debug_mode_enabled : bool = false

Sets whether Curl verbose mode will be enabled or not. Defaults to false.

__destruct()

The main class destructor that closes the current CURL session.

public __destruct() : mixed

get()

Make an HTTP GET request.

public get(string $resource[, array<string|int, mixed> $params = [] ]) : HTTP
Parameters
$resource : string

A resource on the server to use.

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

Request parameters (optional.)

Return values
HTTP

response from the server.

get_domain()

Get domain name from the server URL.

public get_domain() : Domain
Return values
Domain

name as a string.

get_port()

Get server port from the URL.

public get_port() : Port
Return values
Port

number;

get_server()

Get the current server.

public get_server() : HTTP
Return values
HTTP

server link as a string.

post()

Make an HTTP POST request.

public post(string $resource,  $data[, array<string|int, mixed> $params = [] ][, array<string|int, mixed> $headers = [] ]) : HTTP
Parameters
$resource : string

A resource on the server to use.

$data :

A data to post.

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

Request parameters (optional.)

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

Request headers (optional.)

Return values
HTTP

response from the server.

post_file()

Post a file to a server.

public post_file(string $resource, string $file_path[, array<string|int, mixed> $params = [] ][, array<string|int, mixed> $headers = [] ]) : mixed
Parameters
$resource : string

A resource on the server to use.

$file_path : string

A full path to a file.

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

Request parameters (optional.)

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

Request headers (optional.)

put()

Make an HTTP PUT request.

public put(string $resource,  $data[, array<string|int, mixed> $params = [] ][, array<string|int, mixed> $headers = [] ]) : HTTP
Parameters
$resource : string

A resource on the server to use.

$data :

A data array to put.

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

Request parameters (optional.)

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

Request headers (optional.)

Return values
HTTP

response from the server.

set_debug_mode()

Set Curl debug mode to $value.

public set_debug_mode(bool $is_enabled) : void
Parameters
$is_enabled : bool

Is debug mode enabled?

get_curl()

Get Curl handle.

protected get_curl() : mixed
Return values
mixed

Curl handle.

set_opt()

Set Curl option.

protected set_opt(int $option,  $value) : void
Parameters
$option : int

Option to set.

$value :

Value to set.


        
On this page

Search results