| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // | 4 // |
| 5 // VMOptions= | 5 // VMOptions= |
| 6 // VMOptions=--short_socket_read | 6 // VMOptions=--short_socket_read |
| 7 // VMOptions=--short_socket_write | 7 // VMOptions=--short_socket_write |
| 8 // VMOptions=--short_socket_read --short_socket_write | 8 // VMOptions=--short_socket_read --short_socket_write |
| 9 | 9 |
| 10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
| 11 import "dart:async"; | 11 import "dart:async"; |
| 12 import "dart:io"; | 12 import "dart:io"; |
| 13 | 13 |
| 14 void testSimpleDeadline(int connections) { | 14 void testSimpleDeadline(int connections) { |
| 15 HttpServer.bind('localhost', 0).then((server) { | 15 HttpServer.bind('localhost', 0).then((server) { |
| 16 server.listen((request) { | 16 server.listen((request) { |
| 17 request.response.deadline = const Duration(seconds: 10); | 17 request.response.deadline = const Duration(seconds: 1000); |
| 18 request.response.write("stuff"); | 18 request.response.write("stuff"); |
| 19 request.response.close(); | 19 request.response.close(); |
| 20 }); | 20 }); |
| 21 | 21 |
| 22 var futures = []; | 22 var futures = []; |
| 23 var client = new HttpClient(); | 23 var client = new HttpClient(); |
| 24 for (int i = 0; i < connections; i++) { | 24 for (int i = 0; i < connections; i++) { |
| 25 futures.add(client.get('localhost', server.port, '/') | 25 futures.add(client.get('localhost', server.port, '/') |
| 26 .then((request) => request.close()) | 26 .then((request) => request.close()) |
| 27 .then((response) => response.drain())); | 27 .then((response) => response.drain())); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 Future.wait(futures).then((_) => server.close()); | 83 Future.wait(futures).then((_) => server.close()); |
| 84 }); | 84 }); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void main() { | 87 void main() { |
| 88 testSimpleDeadline(10); | 88 testSimpleDeadline(10); |
| 89 testExceedDeadline(10); | 89 testExceedDeadline(10); |
| 90 testDeadlineAndDetach(10); | 90 testDeadlineAndDetach(10); |
| 91 } | 91 } |
| 92 | 92 |
| OLD | NEW |