protected function multiRequest($getCurlObject = false)
{
$mh = curl_multi_init();
$curls = array();
foreach ($this->uri as $absPath => $uri) {
$tempCurl = new curl($uri);
$tempCurl = $this->prepareCurl($tempCurl, $getCurlObject);
$curls[$absPath] = $tempCurl;
curl_multi_add_handle($mh, $tempCurl->getCurl());
}
$active = null;
do {
$mrc = curl_multi_exec($mh, $active);
} while ($active || $mrc == CURLM_CALL_MULTI_PERFORM);
while ($active && CURLM_OK == $mrc) {
if (-1 != curl_multi_select($mh)) {
do {
$mrc = curl_multi_exec($mh, $active);
} while (CURLM_CALL_MULTI_PERFORM == $mrc);
}
}
$responses = array();
foreach ($curls as $key => $curl) {
if (empty($failed)) {
$httpCode = $curl->getinfo(CURLINFO_HTTP_CODE);
if ($httpCode >= 200 && $httpCode < 300) {
if ($getCurlObject) {
$responses[$key] = $curl;
} else {
$responses[$key] = curl_multi_getcontent($curl->getCurl());
}
}
}
curl_multi_remove_handle($mh, $curl->getCurl());
}
curl_multi_close($mh);
return $responses;
}