Skip to content

Commit

Permalink
Adjust request options
Browse files Browse the repository at this point in the history
  • Loading branch information
cerbero90 committed Jan 15, 2024
1 parent 00ca9a3 commit 88bfd80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Concerns/SendsAsyncRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/Sources/Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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());
}

Expand Down

0 comments on commit 88bfd80

Please sign in to comment.