Skip to content

Commit

Permalink
[8.x] Return a new or existing guzzle client based on context (larave…
Browse files Browse the repository at this point in the history
…l#38642)

* Return a new or existing guzzle client based on context

* StyleCI fixes

* Update PendingRequest.php

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
2 people authored and victorvilella committed Oct 12, 2021
1 parent 6478049 commit 26782d1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Illuminate/Http/Client/PendingRequest.php
Expand Up @@ -798,6 +798,28 @@ protected function populateResponse(Response $response)
* @return \GuzzleHttp\Client
*/
public function buildClient()
{
return $this->requestsReusableClient()
? $this->getReusableClient()
: $this->createClient($this->buildHandlerStack());
}

/**
* Determine if a reusable client is required.
*
* @return bool
*/
protected function requestsReusableClient()
{
return ! is_null($this->client) || $this->async;
}

/**
* Retrieve a reusable Guzzle client.
*
* @return \GuzzleHttp\Client
*/
protected function getReusableClient()
{
return $this->client = $this->client ?: $this->createClient($this->buildHandlerStack());
}
Expand Down

0 comments on commit 26782d1

Please sign in to comment.