class DOMClient extends AbstractBrowser

This class provides access to a local or remote http server with a URL as a browser does

Properties

private array $httpserver
private array $parameters

Methods

void
__construct(array $server = array())

Constructor of class DOMClient

static DOMClient
createClient(array $server = array())

Returns an instance of this class as a client to access a local or remote server.

Crawler|string
request(string $method, string $uri, array $parameters = array(), array $files = array(), array $server = array(), string $content = null, bool $changeHistory = true)

Calls a URI and returns a Crawler object to navigate in a list of \DOMNode objects.

Crawler|string
get(string $uri, array $headers = array())

Calls a URI with the GET request method and returns a Crawler object to navigate in a list of \DOMNode objects.

Crawler|string
post(string $uri, array $headers = array(), array $data = array())

Calls a URI with the POST request method and returns a Crawler object to navigate in a list of \DOMNode objects.

Response
doRequest(object $request)

Executes the request

Response
doRemoteRequest(object $request, string $scheme)

Executes the request to the remote server

Response
doLocalRequest(object $request, string $path)

Executes the request to the local server

string
decodeChunked(string $chunked)

Decodes a chunked content

mixed|string
makeRequestHeader(mixed $request, mixed $contentLength = 0)

function makeRequestHeader

string
makeRemote(array $server)

Makes a socket adress for a remote server

string
getPath(string $uri)

Returns the path part of an uri.

string
encodeData(array|string $data)

Encodes data to be usable in an url or a html form.

string
randomNonce(int $bits = 256)

Generates a random cryptographic nonce

Details

at line 101
void __construct(array $server = array())

Constructor of class DOMClient

Parameters

array $server (default: array() The server parameters

Return Value

void

at line 114
static DOMClient createClient(array $server = array())

Returns an instance of this class as a client to access a local or remote server.

Parameters

array $server (default: array() The server parameters

Return Value

DOMClient The instance of this class

at line 132
Crawler|string request(string $method, string $uri, array $parameters = array(), array $files = array(), array $server = array(), string $content = null, bool $changeHistory = true)

Calls a URI and returns a Crawler object to navigate in a list of \DOMNode objects.

Parameters

string $method The HTTP request method (GET or POST)
string $uri The URI to fetch
array $parameters (default: array()) The Request parameters
array $files (default: array()) An array of uploaded files
array $server (default: array()) An array of server parameters
string $content (default: null) The raw body data
bool $changeHistory (default: true) Whether to update the history or not (only used internally for back(), forward(), and reload())

Return Value

Crawler|string The Crawler object or the Response content

at line 151
Crawler|string get(string $uri, array $headers = array())

Calls a URI with the GET request method and returns a Crawler object to navigate in a list of \DOMNode objects.

Parameters

string $uri The URI to fetch
array $headers (default: array() The headers of the request

Return Value

Crawler|string The Crawler object or the Response content

at line 165
Crawler|string post(string $uri, array $headers = array(), array $data = array())

Calls a URI with the POST request method and returns a Crawler object to navigate in a list of \DOMNode objects.

Parameters

string $uri The URI to fetch
array $headers The headers of the request
array $data The data to post

Return Value

Crawler|string The Crawler object or the Response content

at line 177
protected Response doRequest(object $request)

Executes the request

Parameters

object $request The request instance

Return Value

Response The response of the server

at line 200
private Response doRemoteRequest(object $request, string $scheme)

Executes the request to the remote server

Parameters

object $request The request instance
string $scheme The scheme (http or https) of the request

Return Value

Response The response of the server

at line 273
private Response doLocalRequest(object $request, string $path)

Executes the request to the local server

Parameters

object $request The request instance
string $path The path of the uri resource relatively to the DOCUMENT_ROOT

Return Value

Response The response of the server

at line 298
private string decodeChunked(string $chunked)

Decodes a chunked content

Parameters

string $chunked The chunked content

Return Value

string The decoded content

at line 317
private mixed|string makeRequestHeader(mixed $request, mixed $contentLength = 0)

function makeRequestHeader

Parameters

mixed $request
mixed $contentLength (default: 0)

Return Value

mixed|string

at line 356
string makeRemote(array $server)

Makes a socket adress for a remote server

Parameters

array $server The server parameters

Return Value

string The socket adress

at line 374
string getPath(string $uri)

Returns the path part of an uri.

Parameters

string $uri The uri

Return Value

string The path part of the uri

at line 391
string encodeData(array|string $data)

Encodes data to be usable in an url or a html form.

Parameters

array|string $data The data to be encoded

Return Value

string The encoded data

at line 417
string randomNonce(int $bits = 256)

Generates a random cryptographic nonce

Parameters

int $bits (default: 256) The number of bits of the nonce

Return Value

string The cryptographic nonce