56 public function wait(?Http\
Promise $targetPromise =
null): array
58 $processedPromises = [];
60 if (empty($this->promises))
62 return $processedPromises;
71 $status = curl_multi_exec($this->handle, $active);
78 $info = curl_multi_info_read($this->handle);
82 $promiseId = spl_object_hash($info[
'handle']);
84 $promise = $this->promises[$promiseId];
85 $handler = $promise->getHandler();
90 $promise->fulfill($handler->getResponse());
92 elseif ($info[
'result'] === CURLE_OK)
94 $response = $handler->getResponse();
102 $response->adjustHeaders();
104 $promise->fulfill($response);
108 $error = curl_error($info[
'handle']);
110 $promise->reject(
new Http\
NetworkException($promise->getRequest(), $error));
112 if ($logger = $handler->getLogger())
114 $logger->error($error);
119 $processedPromises[] = $promise;
121 $this->
delete($promiseId);
123 if ($targetPromise && $promiseId === $targetPromise->getId())
126 return $processedPromises;
130 while ($status === CURLM_CALL_MULTI_PERFORM || $active);
132 return $processedPromises;