-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Closed
Description
- Laravel Version: 8.75.0
- PHP Version: 8.1.0
- Database Driver & Version: MySQL 8.0.27
Description:
When a retry is specified within the HTTP client, and the retry limit is reached, then the response is automatically thrown. Since there is no way to hook into the throw method, you'll always get a RequestException. Therefore, you cannot do things like $response->failed()
The problem lies within Illuminate\Http\Client\PendingRequest, on lines 682-684:
if ($this->tries > 1 && ! $response->successful()) {
$response->throw();
}Steps To Reproduce:
Simply, add a retry configuration to the HTTP client:
Http::fake([
'*' => Http::response(['error'], 403),
]);
$response = Http::retry(3, 5000)->post('https://example.com/route');
// The above line throws a RequestException, so the below error handling will not be reached
if ($response->failed()) {
// error handling
}Metadata
Metadata
Assignees
Labels
No labels