CurlMultiHandler
in package
Returns an asynchronous response using curl_multi_* functions.
When using the CurlMultiHandler, custom curl options can be specified as an associative array of curl option constants mapping to values in the curl key of the provided request options.
Tags
Table of Contents
Properties
- $_mh : resource|CurlMultiHandle
- $active : int
- $delays : array<int, float>
- $factory : CurlFactoryInterface
- $handles : array<string|int, mixed>
- $options : array<string|int, mixed>
- $selectTimeout : int
Methods
- __construct() : mixed
- This handler accepts the following options:
- __destruct() : mixed
- __get() : resource|CurlMultiHandle
- __invoke() : PromiseInterface
- execute() : void
- Runs until all outstanding connections have completed.
- tick() : void
- Ticks the curl event loop.
- addRequest() : void
- cancel() : bool
- Cancels a handle from sending and removes references to it.
- processMessages() : void
- tickInQueue() : void
- Runs \curl_multi_exec() inside the event loop, to prevent busy looping
- timeToNext() : int
Properties
$_mh
private
resource|CurlMultiHandle
$_mh
$active
private
int
$active
= 0
Will be higher than 0 when curl_multi_exec
is still running.
$delays
private
array<int, float>
$delays
= []
An array of delay times, indexed by handle id in addRequest
.
Tags
$factory
private
CurlFactoryInterface
$factory
$handles
private
array<string|int, mixed>
$handles
= []
Request entry handles, indexed by handle id in addRequest
.
Tags
$options
private
array<string|int, mixed>
$options
= []
An associative array of CURLMOPT_* options and corresponding values for curl_multi_setopt()
$selectTimeout
private
int
$selectTimeout
Methods
__construct()
This handler accepts the following options:
public
__construct([array<string|int, mixed> $options = [] ]) : mixed
- handle_factory: An optional factory used to create curl handles
- select_timeout: Optional timeout (in seconds) to block before timing out while selecting curl handles. Defaults to 1 second.
- options: An associative array of CURLMOPT_* options and corresponding values for curl_multi_setopt()
Parameters
- $options : array<string|int, mixed> = []
__destruct()
public
__destruct() : mixed
__get()
public
__get(string $name) : resource|CurlMultiHandle
Parameters
- $name : string
Tags
Return values
resource|CurlMultiHandle__invoke()
public
__invoke(RequestInterface $request, array<string|int, mixed> $options) : PromiseInterface
Parameters
- $request : RequestInterface
- $options : array<string|int, mixed>
Return values
PromiseInterfaceexecute()
Runs until all outstanding connections have completed.
public
execute() : void
tick()
Ticks the curl event loop.
public
tick() : void
addRequest()
private
addRequest(array<string|int, mixed> $entry) : void
Parameters
- $entry : array<string|int, mixed>
cancel()
Cancels a handle from sending and removes references to it.
private
cancel(int $id) : bool
Parameters
- $id : int
-
Handle ID to cancel and remove.
Return values
bool —True on success, false on failure.
processMessages()
private
processMessages() : void
tickInQueue()
Runs \curl_multi_exec() inside the event loop, to prevent busy looping
private
tickInQueue() : void
timeToNext()
private
timeToNext() : int