commit | f7ece71252df3e9ba683e5a1170eab7c2fe57ae6 | [log] [tgz] |
---|---|---|
author | nweiz@google.com <nweiz@google.com> | Thu Jul 24 22:15:30 2014 +0000 |
committer | nweiz@google.com <nweiz@google.com> | Thu Jul 24 22:15:30 2014 +0000 |
tree | 9b07b28774e048a8106e57f72c4a8d5aa763a96f |
Add an http_throttle package. BUG=20058 R=alanknight@google.com Review URL: https://codereview.chromium.org//418103004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/http_throttle@38560 260f80e4-7a28-3924-810f-c04153c831b5
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); })); }