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

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

Issue 486853005: Fix idle connection pool issue in dart:io's HttpClient (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed existing tests, removed bogus test, use async_helper for new test Created 6 years, 4 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
Index: dart/tests/standalone/io/http_client_timeout_test.dart
diff --git a/dart/tests/standalone/io/http_client_timeout_test.dart b/dart/tests/standalone/io/http_client_timeout_test.dart
deleted file mode 100644
index 0703abb4bc4fa9e747dad808729a5ac2743cd4c5..0000000000000000000000000000000000000000
--- a/dart/tests/standalone/io/http_client_timeout_test.dart
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'dart:async';
-import 'dart:io';
-
-
-void testOneRequest(int connections) {
- HttpServer.bind('127.0.0.1', 0).then((server) {
- server.listen((request) => request.response.close());
- var client = new HttpClient();
- var futures = [];
- for (int i = 0; i < connections; i++) {
- futures.add(
- client.get('127.0.0.1', server.port, '/')
- .then((request) => request.close())
- .then((response) => response.fold(null, (x, y) {})));
- }
- Future.wait(futures).then((_) {
- new Timer.periodic(const Duration(milliseconds: 100), (timer) {
- if (server.connectionsInfo().total == 0) {
- timer.cancel();
- server.close();
- }
- });
- });
- });
-}
-
-
-void testIdleTimeout(int timeout) {
- HttpServer.bind('127.0.0.1', 0).then((server1) {
- HttpServer.bind('127.0.0.1', 0).then((server2) {
- server1.listen((request) => request.pipe(request.response));
- server2.listen((request) => request.pipe(request.response));
-
- var client = new HttpClient();
- client.idleTimeout = new Duration(milliseconds: timeout);
-
- // Create a 'slow' connection..
- Future connect(int port) {
- return client.post('127.0.0.1', port, '/')
- .then((request) {
- request.write("data");
- new Timer(const Duration(milliseconds: 250), () {
- request.close();
- });
- return request.done;
- })
- .then((response) {
- return response.fold(null, (x, y) {});
- });
- }
-
- // Create a single, slow request, to server1.
- connect(server1.port);
-
- // Create a repeating connection to server2.
- run() {
- connect(server2.port).then((_) {
- if (server1.connectionsInfo().total == 0) {
- server1.close();
- server2.close();
- return;
- }
- Timer.run(run);
- });
- }
- run();
- });
- });
-}
-
-
-main() {
- testOneRequest(1);
- testOneRequest(5);
- testOneRequest(20);
- testIdleTimeout(0);
- testIdleTimeout(100);
- testIdleTimeout(500);
- testIdleTimeout(1000);
- testIdleTimeout(2000);
-}
« no previous file with comments | « dart/tests/standalone/io/http_client_stays_alive_test.dart ('k') | dart/tests/standalone/io/http_cross_process_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698