| 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);
|
| }
|
|
|