Clone this repo:
  1. b7aad53 Merge pull request #19 from dart-lang/franklinyow-patch-1 by Franklin Yow · 4 weeks ago master
  2. efb28e0 Update LICENSE by Franklin Yow · 4 weeks ago franklinyow-patch-1
  3. 56adf66 Prepare to publish null safety release (#18) by Nate Bosch · 8 weeks ago 0.2.0
  4. 845771a Migrate to null safety (#17) by Nate Bosch · 8 weeks ago
  5. c140142 Migrate to GitHub Actions (#16) by Alexander Thomas · 3 months 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.