commit | 7d77b3c1a79cb35075a270790068c1c4b45636af | [log] [tgz] |
---|---|---|
author | Devon Carew <devoncarew@google.com> | Fri Apr 29 16:25:39 2022 -0700 |
committer | GitHub <noreply@github.com> | Fri Apr 29 16:25:39 2022 -0700 |
tree | a1a13791a915666b7496569e27f24dc387eae92c | |
parent | 544feddd342568cfa7b2129b9caadb7cd7bffd50 [diff] |
Update pubspec.yaml
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.