diff --git a/src/Concerns/SendsAsyncRequests.php b/src/Concerns/SendsAsyncRequests.php index 86ae466..062f9e0 100644 --- a/src/Concerns/SendsAsyncRequests.php +++ b/src/Concerns/SendsAsyncRequests.php @@ -8,6 +8,7 @@ use GuzzleHttp\Client; use GuzzleHttp\Pool; use GuzzleHttp\Psr7\Uri; +use GuzzleHttp\RequestOptions; use Illuminate\Support\LazyCollection; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -32,8 +33,9 @@ trait SendsAsyncRequests protected function fetchItemsAsynchronously(LazyCollection $chunkedPages, UriInterface $uri): Traversable { $client = new Client([ - 'timeout' => $this->config->requestTimeout, - 'connect_timeout' => $this->config->connectionTimeout, + RequestOptions::TIMEOUT => $this->config->requestTimeout, + RequestOptions::CONNECT_TIMEOUT => $this->config->connectionTimeout, + RequestOptions::STREAM => true, ]); foreach ($chunkedPages as $pages) { diff --git a/src/Sources/Endpoint.php b/src/Sources/Endpoint.php index a0cb3c0..e6cd8a2 100644 --- a/src/Sources/Endpoint.php +++ b/src/Sources/Endpoint.php @@ -8,6 +8,7 @@ use Cerbero\LazyJsonPages\ValueObjects\Response; use GuzzleHttp\Client; use GuzzleHttp\Psr7\Request; +use GuzzleHttp\RequestOptions; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\UriInterface; @@ -58,7 +59,7 @@ public function request(): RequestInterface public function response(?string $key = null): mixed { if (!$this->response) { - $response = (new Client())->send($this->request()); + $response = (new Client([RequestOptions::STREAM => true]))->send($this->request()); $this->response = new Response($response->getBody()->getContents(), $response->getHeaders()); }