function need_two_good_results in HTTP Parallel Request & Threading Library 6
Same name and namespace in other branches
- 7 examples/httprl.examples.php \need_two_good_results()
1 string reference to 'need_two_good_results'
- httprl.examples.php in examples/httprl.examples.php
- HTTP Parallel Request Library code examples.
File
- examples/httprl.examples.php, line 326
- HTTP Parallel Request Library code examples.
Code
function need_two_good_results($id, &$responses) {
static $counter = 0;
foreach ($responses as $id => &$result) {
if ($result->code == 200 || $result->code == 206) {
$counter += 1;
continue;
}
if ($result->status == 'Done.') {
continue;
}
if ($counter >= 2) {
$result->code = HTTPRL_REQUEST_ABORTED;
$result->error = 'Software caused connection abort.';
$result->status = 'Done.';
$result->options['timeout'] -= $result->running_time;
fclose($result->fp);
unset($result->fp);
}
}
}