commit | 7ad83ad8df97a99ddc85065c59fd863135fb3149 | [log] [tgz] |
---|---|---|
author | Natalie Weizenbaum <nweiz@google.com> | Tue Dec 12 14:51:55 2017 -0800 |
committer | Natalie Weizenbaum <nweiz@google.com> | Tue Dec 12 14:51:55 2017 -0800 |
tree | 063f5cd9bc8a914fef94d07345e25d89e58069d6 | |
parent | 694e34facb6c541640b22d1835890affc9cc6e58 [diff] |
Pass BaseResponse to when() This makes it clear that callers shouldn't try to read the response body in the callback.
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.