tree: b9274d6047caede1725e469b87c3c7982cf0b64b [path history] [tgz]
  1. lib/
  2. test/
  3. .gitignore
  4. .test_config
  5. .travis.yml
  6. CHANGELOG.md
  7. codereview.settings
  8. LICENSE
  9. pubspec.yaml
  10. README.md
README.md

http_throttle is middleware for the http package that throttles the number of concurrent requests that an HTTP client can make.

// This client allows 32 concurrent requests.
final client = new ThrottleClient(32);

Future<List<String>> readAllUrls(Iterable<Uri> urls) {
  return Future.wait(urls.map((url) {
    // You can safely call as many client methods as you want concurrently, and
    // ThrottleClient will ensure that only 32 underlying HTTP requests will be
    // open at once.
    return client.read(url);
  }));
}