Skip to content

Commit

Permalink
[8.x] Return a new or existing guzzle client based on context (#38642)
Browse files Browse the repository at this point in the history
* 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
craigballinger and taylorotwell committed Sep 2, 2021
1 parent 782cef2 commit 658069b
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 658069b

Please sign in to comment.