Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Unified Diff: tests/standalone/io/http_client_connect_test.dart

Issue 311513002: Enable throttleing of HttpClient per host, with default being 6. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/io.dart ('k') | tests/standalone/io/http_response_deadline_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/http_client_connect_test.dart
diff --git a/tests/standalone/io/http_client_connect_test.dart b/tests/standalone/io/http_client_connect_test.dart
index 8e183252129a2245a5db3ea8589b7b7cc3dd6e9c..841944c00ee4bbe96edc2a48dad013b9cdd2553b 100644
--- a/tests/standalone/io/http_client_connect_test.dart
+++ b/tests/standalone/io/http_client_connect_test.dart
@@ -248,6 +248,35 @@ void testNoBuffer() {
});
}
+void testMaxConnectionsPerHost(int connectionCap, int connections) {
+ asyncStart();
+ HttpServer.bind("127.0.0.1", 0).then((server) {
+ int handled = 0;
+ server.listen((request) {
+ Expect.isTrue(server.connectionsInfo().total <= connectionCap);
+ request.response.close();
+ handled++;
+ if (handled == connections) {
+ asyncEnd();
+ server.close();
+ }
+ });
+
+ var client = new HttpClient();
+ client.maxConnectionsPerHost = connectionCap;
+ for (int i = 0; i < connections; i++) {
+ asyncStart();
+ client.get("127.0.0.1", server.port, "/")
+ .then((request) => request.close())
+ .then((response) {
+ response.listen(null, onDone: () {
+ asyncEnd();
+ });
+ });
+ }
+ });
+}
+
void main() {
testGetEmptyRequest();
@@ -260,4 +289,8 @@ void main() {
testOpenEmptyRequest();
testOpenUrlEmptyRequest();
testNoBuffer();
+ testMaxConnectionsPerHost(1, 1);
+ testMaxConnectionsPerHost(1, 10);
+ testMaxConnectionsPerHost(5, 10);
+ testMaxConnectionsPerHost(10, 50);
}
« no previous file with comments | « sdk/lib/io/io.dart ('k') | tests/standalone/io/http_response_deadline_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698