function background_process_http_request_process in Background Process 7.2
Same name and namespace in other branches
- 8 background_process.module \background_process_http_request_process()
- 6 background_process.module \background_process_http_request_process()
- 7 background_process.module \background_process_http_request_process()
Process multiple http requests.
File
- ./
background_process.http.inc, line 415 - This contains the HTTP functions for Background Process.
Code
function background_process_http_request_process(&$results, $options = array()) {
$options += array(
'timeout' => 30,
'interval' => 0.01,
'limit' => 0,
);
$interval = $options['interval'] * 1000000;
$expire = time() + $options['timeout'];
while ($results && time() < $expire) {
$cnt = 0;
$data_ready = FALSE;
foreach ($results as $i => &$result) {
if (isset($result->code)) {
continue;
}
background_process_http_request_get_response($result);
$data_ready = $data_ready || $result->data_ready ? TRUE : FALSE;
$cnt++;
if ($options['limit'] && $cnt >= $options['limit']) {
break;
}
}
if (!$cnt) {
break;
}
if (!$data_ready) {
usleep($interval);
}
}
}