diff --git a/src/Illuminate/Http/Client/PendingRequest.php b/src/Illuminate/Http/Client/PendingRequest.php index d5426fb09cdd..40a3a8755753 100644 --- a/src/Illuminate/Http/Client/PendingRequest.php +++ b/src/Illuminate/Http/Client/PendingRequest.php @@ -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()); }