From 976751bf82f7206511690eee82da01c528080763 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Wed, 12 May 2021 13:39:50 +0100 Subject: [PATCH] [8.x] Avoid deprecated guzzle code (#37349) * Avoid deprecated guzzle code * Fixed typo * Fixed typo --- src/Illuminate/Http/Client/Factory.php | 7 +++++-- src/Illuminate/Http/Client/RequestException.php | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Http/Client/Factory.php b/src/Illuminate/Http/Client/Factory.php index 7d373f762e03..f6256f16ad42 100644 --- a/src/Illuminate/Http/Client/Factory.php +++ b/src/Illuminate/Http/Client/Factory.php @@ -3,7 +3,6 @@ namespace Illuminate\Http\Client; use Closure; -use function GuzzleHttp\Promise\promise_for; use GuzzleHttp\Psr7\Response as Psr7Response; use Illuminate\Support\Str; use Illuminate\Support\Traits\Macroable; @@ -109,7 +108,11 @@ public static function response($body = null, $status = 200, $headers = []) $headers['Content-Type'] = 'application/json'; } - return promise_for(new Psr7Response($status, $headers, $body)); + $response = new Psr7Response($status, $headers, $body); + + return class_exists(GuzzleHttp\Promise\Create::class) + ? \GuzzleHttp\Promise\Create::promiseFor($response) + : \GuzzleHttp\Promise\promise_for($response); } /** diff --git a/src/Illuminate/Http/Client/RequestException.php b/src/Illuminate/Http/Client/RequestException.php index fe2ea8be4252..fa4f418398ae 100644 --- a/src/Illuminate/Http/Client/RequestException.php +++ b/src/Illuminate/Http/Client/RequestException.php @@ -34,7 +34,9 @@ protected function prepareMessage(Response $response) { $message = "HTTP request returned status code {$response->status()}"; - $summary = \GuzzleHttp\Psr7\get_message_body_summary($response->toPsrResponse()); + $summary = class_exists(\GuzzleHttp\Psr7\Message::class) + ? \GuzzleHttp\Psr7\Message::bodySummary($response->toPsrResponse()) + : \GuzzleHttp\Psr7\get_message_body_summary($response->toPsrResponse()); return is_null($summary) ? $message : $message .= ":\n{$summary}\n"; }