Clone this repo:
  1. a021aa5 Increase description length to be >= 60 characters by Kevin Moore · 5 days ago master
  2. 695d8bd Add an example and fix example in readme by Kevin Moore · 5 days ago
  3. eb13288 Remove pubspec author and outdated URLs by Kevin Moore · 5 days ago
  4. 5574029 enable and fix a number of lints by Kevin Moore · 5 days ago
  5. 062ac55 Remove duplicate pedantic items by Kevin Moore · 5 days ago

Middleware for the http package that transparently retries failing requests.

To use this, just create an RetryClient that wraps the underlying http.Client:

import 'package:http/http.dart' as http;
import 'package:http_retry/http_retry.dart';

Future<void> main() async {
  final client = RetryClient(http.Client());
  try {
    print(await client.read('http://example.org'));
  } finally {
    client.close();
  }
}

By default, this retries any request whose response has status code 503 Temporary Failure up to three retries. It waits 500ms before the first retry, and increases the delay by 1.5x each time. All of this can be customized using the RetryClient() constructor.