From aa174beb950a5ab65b968a46aff5b7567e1a86c8 Mon Sep 17 00:00:00 2001 From: Luke Kuzmish <42181698+cosmastech@users.noreply.github.com> Date: Wed, 26 Nov 2025 17:59:13 -0500 Subject: [PATCH] Update PendingRequest.php --- src/Illuminate/Http/Client/PendingRequest.php | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/Illuminate/Http/Client/PendingRequest.php b/src/Illuminate/Http/Client/PendingRequest.php index 1769c6f35695..31e0462bbadb 100644 --- a/src/Illuminate/Http/Client/PendingRequest.php +++ b/src/Illuminate/Http/Client/PendingRequest.php @@ -968,32 +968,34 @@ public function send(string $method, string $url, array $options = []) $this->dispatchResponseReceivedEvent($response); - if (! $response->successful()) { - try { - $shouldRetry = $this->retryWhenCallback ? call_user_func($this->retryWhenCallback, $response->toException(), $this, $this->request->toPsrRequest()->getMethod()) : true; - } catch (Exception $exception) { - $shouldRetry = false; - - throw $exception; - } - - if ($this->throwCallback && - ($this->throwIfCallback === null || - call_user_func($this->throwIfCallback, $response))) { - $response->throw($this->throwCallback); - } - - $potentialTries = is_array($this->tries) - ? count($this->tries) + 1 - : $this->tries; - - if ($attempt < $potentialTries && $shouldRetry) { - $response->throw(); - } - - if ($potentialTries > 1 && $this->retryThrow) { - $response->throw(); - } + if ($response->successful()) { + return; + } + + try { + $shouldRetry = $this->retryWhenCallback ? call_user_func($this->retryWhenCallback, $response->toException(), $this, $this->request->toPsrRequest()->getMethod()) : true; + } catch (Exception $exception) { + $shouldRetry = false; + + throw $exception; + } + + if ($this->throwCallback && + ($this->throwIfCallback === null || + call_user_func($this->throwIfCallback, $response))) { + $response->throw($this->throwCallback); + } + + $potentialTries = is_array($this->tries) + ? count($this->tries) + 1 + : $this->tries; + + if ($attempt < $potentialTries && $shouldRetry) { + $response->throw(); + } + + if ($potentialTries > 1 && $this->retryThrow) { + $response->throw(); } }); } catch (TransferException $e) {