24 lines
947 B
PHP
24 lines
947 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace app\common\service;
|
|
|
|
// Adapt the existing synchronous HTTP fixtures to the cancellable multi pump.
|
|
function curl_multi_init(): \stdClass { return new \stdClass(); }
|
|
function curl_multi_add_handle(\stdClass $multi, \stdClass $handle): int { $multi->handle = $handle; return CURLM_OK; }
|
|
function curl_multi_exec(\stdClass $multi, ?int &$running): int {
|
|
curl_exec($multi->handle);
|
|
$multi->completion = ['handle' => $multi->handle, 'result' => curl_errno($multi->handle)];
|
|
$running = 0;
|
|
return CURLM_OK;
|
|
}
|
|
function curl_multi_info_read(\stdClass $multi): array|false {
|
|
$info = $multi->completion ?? false;
|
|
unset($multi->completion);
|
|
return $info;
|
|
}
|
|
function curl_multi_select(\stdClass $multi, float $timeout): int { return 0; }
|
|
function curl_multi_remove_handle(\stdClass $multi, \stdClass $handle): int { return CURLM_OK; }
|
|
function curl_multi_close(\stdClass $multi): void {}
|