Clone this repo:
  1. 7b505c8 Bump dart-lang/setup-dart from 0.3 to 1 (#20) by dependabot[bot] · 8 weeks ago master
  2. fdf3a9c Add dependabot by Kevin Moore · 8 weeks ago
  3. b7aad53 Merge pull request #19 from dart-lang/franklinyow-patch-1 by Franklin Yow · 4 months ago
  4. efb28e0 Update LICENSE by Franklin Yow · 4 months ago franklinyow-patch-1
  5. 56adf66 Prepare to publish null safety release (#18) by Nate Bosch · 5 months ago 0.2.0

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.