class StreamClient extends AbstractHTTPClient (View source)

Connection handler using PHPs stream wrappers.

Requires PHP being compiled with --with-curlwrappers for now, since the PHPs own HTTP implementation is somehow b0rked.

Properties

protected array $options CouchDB connection options. from AbstractHTTPClient
protected resource $httpFilePointer Connection pointer for connections, once keep alive is working on the CouchDb side.

Methods

__construct(string $host = 'localhost', int $port = 5984, string $username = null, string $password = null, string $ip = null, bool $ssl = false, string $path = null, int $timeout = 10, array $headers = [])

Construct a CouchDB connection.

void
setOption(string $option, mixed $value)

Set option value.

array
getOptions()

Get the connection options.

resource
getConnection(string $method, string $path, string $data = null, array $headers = [])

Return the connection pointer after setting up the stream connection.

checkConnection($method, $path, $data, $headers)

Sets up the stream connection.

array
getStreamHeaders($connection = null)

No description

request(string $method, string $path, string $data = null, bool $raw = false, array $headers = [])

Perform a request to the server and return the result.

Details

AbstractHTTPClient __construct(string $host = 'localhost', int $port = 5984, string $username = null, string $password = null, string $ip = null, bool $ssl = false, string $path = null, int $timeout = 10, array $headers = [])

Construct a CouchDB connection.

Construct a CouchDB connection from basic connection parameters for one given database.

Parameters

string $host
int $port
string $username
string $password
string $ip
bool $ssl
string $path
int $timeout
array $headers

Return Value

AbstractHTTPClient

void setOption(string $option, mixed $value)

Set option value.

Set the value for an connection option. Throws an InvalidArgumentException for unknown options.

Parameters

string $option
mixed $value

Return Value

void

Exceptions

InvalidArgumentException

array getOptions()

Get the connection options.

Return Value

array

resource getConnection(string $method, string $path, string $data = null, array $headers = [])

Return the connection pointer after setting up the stream connection.

The returned resource can later be used to read data in chunks.

Parameters

string $method
string $path
string $data
array $headers

Return Value

resource

Exceptions

HTTPException

protected checkConnection($method, $path, $data, $headers)

Sets up the stream connection.

Parameters

$method
$path
$data
$headers

Exceptions

HTTPException

array getStreamHeaders($connection = null)

Parameters

$connection

Return Value

array

Response request(string $method, string $path, string $data = null, bool $raw = false, array $headers = [])

Perform a request to the server and return the result.

Perform a request to the server and return the result converted into a Response object. If you do not expect a JSON structure, which could be converted in such a response object, set the forth parameter to true, and you get a response object returned, containing the raw body.

Parameters

string $method
string $path
string $data
bool $raw
array $headers

Return Value

Response

Exceptions

HTTPException