MediaWiki
1.34.0
|
Class to handle multiple HTTP requests. More...
Public Member Functions | |
__construct (array $options) | |
__destruct () | |
run (array $req, array $opts=[]) | |
Execute an HTTP(S) request. More... | |
runMulti (array $reqs, array $opts=[]) | |
Execute a set of HTTP(S) requests. More... | |
setLogger (LoggerInterface $logger) | |
Register a logger. More... | |
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. More... | |
Protected Attributes | |
string null | $caBundlePath |
SSL certificates path. More... | |
float | $connTimeout = 10 |
LoggerInterface | $logger |
int | $maxConnsPerHost = 50 |
resource | $multiHandle = null |
string null | $proxy |
proxy More... | |
float | $reqTimeout = 900 |
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. More... | |
normalizeRequests (array &$reqs) | |
Normalize request information. More... | |
runMultiCurl (array $reqs, array $opts) | |
Execute a set of HTTP(S) requests concurrently. More... | |
runMultiHttp (array $reqs, array $opts=[]) | |
Execute a set of HTTP(S) requests sequentially. More... | |
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 600 of file MultiHttpClient.php.
|
protected |
array | &$req | HTTP request map |
-param array{url:string,proxy?:?string,query:mixed,method:string,body:string|resource,headers:string[],stream?:resource,flags:array} $req
array | $opts |
|
Exception |
Definition at line 306 of file MultiHttpClient.php.
References $header, $matches, and $userAgent.
Referenced by runMultiCurl().
|
protected |
Exception |
Definition at line 430 of file MultiHttpClient.php.
References $multiHandle.
Referenced by runMultiCurl().
|
private |
Get a suitable select timeout for the given options.
array | $opts |
Definition at line 575 of file MultiHttpClient.php.
References $connTimeout, $reqTimeout, and TIMEOUT_ACCURACY_FACTOR.
Referenced by runMultiCurl().
|
protected |
Determines if the curl extension is available.
Definition at line 178 of file MultiHttpClient.php.
Referenced by runMulti().
|
private |
Normalize request information.
array[] | $reqs | the requests to normalize |
Definition at line 530 of file MultiHttpClient.php.
Referenced by runMulti().
MultiHttpClient::run | ( | array | $req, |
array | $opts = [] |
||
) |
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().
MultiHttpClient::runMulti | ( | array | $reqs, |
array | $opts = [] |
||
) |
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 $connTimeout, $reqTimeout, isCurlEnabled(), normalizeRequests(), runMultiCurl(), and runMultiHttp().
Referenced by run().
|
private |
Execute a set of HTTP(S) requests concurrently.
array[] | $reqs | Map of HTTP request arrays |
array | $opts |
|
-param array{connTimeout?:int,reqTimeout?:int,usePipelining?:bool,maxConnsPerHost?:int} $opts
Exception | PhanTypeInvalidDimOffset |
Definition at line 200 of file MultiHttpClient.php.
References getCurlHandle(), getCurlMulti(), and getSelectTimeout().
Referenced by runMulti().
|
private |
Execute a set of HTTP(S) requests sequentially.
array | $reqs | Map of HTTP request arrays |
array | $opts |
|
Exception |
Definition at line 457 of file MultiHttpClient.php.
References $caBundlePath, $connTimeout, $logger, $proxy, $reqTimeout, and $userAgent.
Referenced by runMulti().
MultiHttpClient::setLogger | ( | LoggerInterface | $logger | ) |
Register a logger.
LoggerInterface | $logger |
Definition at line 596 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(), runMulti(), 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(), runMulti(), 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().