From 64ed229266daaab0e0593f9802f5cf9bd7a27ed9 Mon Sep 17 00:00:00 2001 From: Craig Ballinger Date: Wed, 1 Sep 2021 21:40:00 -0400 Subject: [PATCH 1/3] Return a new or existing guzzle client based on context --- src/Illuminate/Http/Client/PendingRequest.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Illuminate/Http/Client/PendingRequest.php b/src/Illuminate/Http/Client/PendingRequest.php index d5426fb09cdd..6749d1d3a479 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 + */ + public function requestsReusableClient() + { + return !is_null($this->client) || $this->async; + } + + /** + * Retrieve a reusable Guzzle client. + * + * @return \GuzzleHttp\Client + */ + public function getReusableClient() { return $this->client = $this->client ?: $this->createClient($this->buildHandlerStack()); } From 13d2e6f0a8e06875f52964aefa831eb0ce4bd052 Mon Sep 17 00:00:00 2001 From: Craig Ballinger Date: Wed, 1 Sep 2021 22:20:33 -0400 Subject: [PATCH 2/3] StyleCI fixes --- src/Illuminate/Http/Client/PendingRequest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Http/Client/PendingRequest.php b/src/Illuminate/Http/Client/PendingRequest.php index 6749d1d3a479..a5390e848fd6 100644 --- a/src/Illuminate/Http/Client/PendingRequest.php +++ b/src/Illuminate/Http/Client/PendingRequest.php @@ -805,13 +805,13 @@ public function buildClient() } /** - * Determine if a reusable client is required + * Determine if a reusable client is required. * * @return bool */ public function requestsReusableClient() { - return !is_null($this->client) || $this->async; + return ! is_null($this->client) || $this->async; } /** From 1fdc005f78bb6e19e36c5661832dc9a9645fc2cd Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 2 Sep 2021 09:04:52 -0500 Subject: [PATCH 3/3] Update PendingRequest.php --- src/Illuminate/Http/Client/PendingRequest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Http/Client/PendingRequest.php b/src/Illuminate/Http/Client/PendingRequest.php index a5390e848fd6..40a3a8755753 100644 --- a/src/Illuminate/Http/Client/PendingRequest.php +++ b/src/Illuminate/Http/Client/PendingRequest.php @@ -809,7 +809,7 @@ public function buildClient() * * @return bool */ - public function requestsReusableClient() + protected function requestsReusableClient() { return ! is_null($this->client) || $this->async; } @@ -819,7 +819,7 @@ public function requestsReusableClient() * * @return \GuzzleHttp\Client */ - public function getReusableClient() + protected function getReusableClient() { return $this->client = $this->client ?: $this->createClient($this->buildHandlerStack()); }