tree: 3d59f3124aa2fbe12f366ffc8058773da99904e8 [path history] [tgz]
  1. .github/
  2. example/
  3. lib/
  4. test/
  5. .gitignore
  6. analysis_options.yaml
  7. AUTHORS
  8. CHANGELOG.md
  9. CONTRIBUTING.md
  10. LICENSE
  11. pubspec.yaml
  12. README.md
README.md

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.