MediaWiki REL1_33
|
Class to handle multiple HTTP requests. More...
Public Member Functions | |
__construct (array $options) | |
__destruct () | |
run (array $req, array $opts=[]) | |
Execute an HTTP(S) request. | |
runMulti (array $reqs, array $opts=[]) | |
Execute a set of HTTP(S) requests. | |
setLogger (LoggerInterface $logger) | |
Register a logger. | |
Public Attributes | |
const | TIMEOUT_ACCURACY_FACTOR = 0.1 |
Protected Member Functions | |
getCurlHandle (array &$req, array $opts=[]) | |
getCurlMulti () | |
isCurlEnabled () | |
Determines if the curl extension is available. | |
Protected Attributes | |
string null | $caBundlePath |
SSL certificates path. | |
float | $connTimeout = 10 |
LoggerInterface | $logger |
int | $maxConnsPerHost = 50 |
resource | $multiHandle = null |
string null | $proxy |
proxy | |
float | $reqTimeout = 300 |
bool | $usePipelining = false |
string | $userAgent = 'wikimedia/multi-http-client v1.0' |
Private Member Functions | |
getSelectTimeout ( $opts) | |
Get a suitable select timeout for the given options. | |
normalizeRequests (array &$reqs) | |
Normalize request information. | |
runMultiCurl (array $reqs, array $opts=[]) | |
Execute a set of HTTP(S) requests concurrently. | |
runMultiHttp (array $reqs, array $opts=[]) | |
Execute a set of HTTP(S) requests sequentially. | |
Class to handle multiple HTTP requests.
If curl is available, requests will be made concurrently. Otherwise, they will be made serially.
HTTP request maps are arrays that use the following format:
Definition at line 52 of file MultiHttpClient.php.
MultiHttpClient::__construct | ( | array | $options | ) |
array | $options |
|
Exception |
Definition at line 89 of file MultiHttpClient.php.
MultiHttpClient::__destruct | ( | ) |
Definition at line 606 of file MultiHttpClient.php.
array | &$req | HTTP request map |
array | $opts |
|
Exception |
Definition at line 299 of file MultiHttpClient.php.
References $data, $header, $matches, $name, $query, $req, $userAgent, $value, as, list, and use.
Referenced by runMultiCurl().
|
protected |
Exception |
Definition at line 437 of file MultiHttpClient.php.
References $multiHandle.
Referenced by runMultiCurl().
|
private |
Get a suitable select timeout for the given options.
array | $opts |
Definition at line 581 of file MultiHttpClient.php.
References $connTimeout, $reqTimeout, e, and TIMEOUT_ACCURACY_FACTOR.
Referenced by runMultiCurl().
|
protected |
Determines if the curl extension is available.
Definition at line 176 of file MultiHttpClient.php.
Referenced by runMulti().
|
private |
Normalize request information.
array | $reqs | the requests to normalize |
Definition at line 536 of file MultiHttpClient.php.
References $name, $req, $value, and as.
Referenced by runMulti().
Execute an HTTP(S) request.
This method returns a response map of:
array | $req | HTTP request array |
array | $opts |
Definition at line 129 of file MultiHttpClient.php.
References runMulti().
Execute a set of HTTP(S) requests.
If curl is available, requests will be made concurrently. Otherwise, they will be made serially.
The maps are returned by this method with the 'response' field set to a map of:
array | $reqs | Map of HTTP request arrays |
array | $opts |
|
Exception |
Definition at line 162 of file MultiHttpClient.php.
References isCurlEnabled(), normalizeRequests(), runMultiCurl(), and runMultiHttp().
Referenced by run().
Execute a set of HTTP(S) requests concurrently.
array | $reqs | Map of HTTP request arrays |
array | $opts |
|
Exception |
Definition at line 196 of file MultiHttpClient.php.
References $batch, $req, as, getCurlHandle(), getCurlMulti(), and getSelectTimeout().
Referenced by runMulti().
Execute a set of HTTP(S) requests sequentially.
array | $reqs | Map of HTTP request arrays |
array | $opts |
|
Exception |
Definition at line 464 of file MultiHttpClient.php.
References $caBundlePath, $connTimeout, $logger, $proxy, $query, $req, $reqTimeout, $userAgent, and as.
Referenced by runMulti().
MultiHttpClient::setLogger | ( | LoggerInterface | $logger | ) |
Register a logger.
LoggerInterface | $logger |
Definition at line 602 of file MultiHttpClient.php.
References $logger.
|
protected |
SSL certificates path.
Definition at line 56 of file MultiHttpClient.php.
Referenced by runMultiHttp().
|
protected |
Definition at line 58 of file MultiHttpClient.php.
Referenced by getSelectTimeout(), and runMultiHttp().
|
protected |
Definition at line 70 of file MultiHttpClient.php.
Referenced by runMultiHttp(), and setLogger().
|
protected |
Definition at line 64 of file MultiHttpClient.php.
|
protected |
Definition at line 54 of file MultiHttpClient.php.
Referenced by getCurlMulti().
|
protected |
|
protected |
Definition at line 60 of file MultiHttpClient.php.
Referenced by getSelectTimeout(), and runMultiHttp().
|
protected |
Definition at line 62 of file MultiHttpClient.php.
|
protected |
Definition at line 68 of file MultiHttpClient.php.
Referenced by getCurlHandle(), and runMultiHttp().
const MultiHttpClient::TIMEOUT_ACCURACY_FACTOR = 0.1 |
Definition at line 75 of file MultiHttpClient.php.
Referenced by getSelectTimeout().