Skip to content

Commit 92f5dc9

Browse files
authored
Update PendingRequest.php (#57943)
1 parent f054d9c commit 92f5dc9

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

src/Illuminate/Http/Client/PendingRequest.php

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -968,32 +968,34 @@ public function send(string $method, string $url, array $options = [])
968968

969969
$this->dispatchResponseReceivedEvent($response);
970970

971-
if (! $response->successful()) {
972-
try {
973-
$shouldRetry = $this->retryWhenCallback ? call_user_func($this->retryWhenCallback, $response->toException(), $this, $this->request->toPsrRequest()->getMethod()) : true;
974-
} catch (Exception $exception) {
975-
$shouldRetry = false;
976-
977-
throw $exception;
978-
}
979-
980-
if ($this->throwCallback &&
981-
($this->throwIfCallback === null ||
982-
call_user_func($this->throwIfCallback, $response))) {
983-
$response->throw($this->throwCallback);
984-
}
985-
986-
$potentialTries = is_array($this->tries)
987-
? count($this->tries) + 1
988-
: $this->tries;
989-
990-
if ($attempt < $potentialTries && $shouldRetry) {
991-
$response->throw();
992-
}
993-
994-
if ($potentialTries > 1 && $this->retryThrow) {
995-
$response->throw();
996-
}
971+
if ($response->successful()) {
972+
return;
973+
}
974+
975+
try {
976+
$shouldRetry = $this->retryWhenCallback ? call_user_func($this->retryWhenCallback, $response->toException(), $this, $this->request->toPsrRequest()->getMethod()) : true;
977+
} catch (Exception $exception) {
978+
$shouldRetry = false;
979+
980+
throw $exception;
981+
}
982+
983+
if ($this->throwCallback &&
984+
($this->throwIfCallback === null ||
985+
call_user_func($this->throwIfCallback, $response))) {
986+
$response->throw($this->throwCallback);
987+
}
988+
989+
$potentialTries = is_array($this->tries)
990+
? count($this->tries) + 1
991+
: $this->tries;
992+
993+
if ($attempt < $potentialTries && $shouldRetry) {
994+
$response->throw();
995+
}
996+
997+
if ($potentialTries > 1 && $this->retryThrow) {
998+
$response->throw();
997999
}
9981000
});
9991001
} catch (TransferException $e) {

0 commit comments

Comments
 (0)