tag | 0674d8f92aa3171c2e154af3f3b07104b872dffa | |
---|---|---|
tagger | Natalie Weizenbaum <nweiz@google.com> | Tue Mar 20 13:15:53 2018 -0700 |
object | 405395b1eb9398966ac784301b6fa5a382bb88c9 |
Add a whenError() callback.
commit | 405395b1eb9398966ac784301b6fa5a382bb88c9 | [log] [tgz] |
---|---|---|
author | Natalie Weizenbaum <nweiz@google.com> | Tue Mar 20 13:14:32 2018 -0700 |
committer | GitHub <noreply@github.com> | Tue Mar 20 13:14:32 2018 -0700 |
tree | 6078f4de20619b1e3c2860ad4d150fc8f08ccd66 | |
parent | 445c47aff19b9031cb2c602b065cad0697b69bdf [diff] |
Add a whenError() callback to retry requests that error (#3) See dart-lang/pub#1826
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'; main() async { var client = new RetryClient(new http.Client()); print(await client.read("http://example.org")); await 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 new RetryClient()
constructor.