From 51b1aead75684683516921d896c2584992d00fad Mon Sep 17 00:00:00 2001 From: Oscar Otero Date: Thu, 30 Nov 2023 14:55:57 +0100 Subject: [PATCH] avoid executing curl_exec twice #527 --- src/Http/CurlDispatcher.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Http/CurlDispatcher.php b/src/Http/CurlDispatcher.php index 5b1f60c6..ac989973 100644 --- a/src/Http/CurlDispatcher.php +++ b/src/Http/CurlDispatcher.php @@ -34,7 +34,8 @@ public static function fetch(array $settings, ResponseFactoryInterface $response { if (count($requests) === 1) { $connection = new static($settings, $requests[0]); - return [$connection->exec($responseFactory)]; + curl_exec($connection->curl); + return [$connection->getResponse($responseFactory)]; } //Init connections @@ -77,7 +78,7 @@ public static function fetch(array $settings, ResponseFactoryInterface $response curl_multi_close($multi); return array_map( - fn ($connection) => $connection->exec($responseFactory), + fn ($connection) => $connection->getResponse($responseFactory), $connections ); } @@ -113,10 +114,8 @@ private function __construct(array $settings, RequestInterface $request, StreamF ]); } - private function exec(ResponseFactoryInterface $responseFactory): ResponseInterface + private function getResponse(ResponseFactoryInterface $responseFactory): ResponseInterface { - curl_exec($this->curl); - $info = curl_getinfo($this->curl); if ($this->error) {