| 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"; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 request.response.deadline = const Duration(milliseconds: 100); | 36 request.response.deadline = const Duration(milliseconds: 100); |
| 37 request.response.contentLength = 10000; | 37 request.response.contentLength = 10000; |
| 38 request.response.write("stuff"); | 38 request.response.write("stuff"); |
| 39 }); | 39 }); |
| 40 | 40 |
| 41 var futures = []; | 41 var futures = []; |
| 42 var client = new HttpClient(); | 42 var client = new HttpClient(); |
| 43 for (int i = 0; i < connections; i++) { | 43 for (int i = 0; i < connections; i++) { |
| 44 futures.add(client.get('localhost', server.port, '/') | 44 futures.add(client.get('localhost', server.port, '/') |
| 45 .then((request) => request.close()) | 45 .then((request) => request.close()) |
| 46 .then((response) { | 46 .then((response) => response.drain()) |
| 47 return response.drain().then((_) { | 47 .then((_) { |
| 48 Expect.fail("Expected error"); | 48 Expect.fail("Expected error"); |
| 49 }, onError: (e) { | 49 }, onError: (e) { |
| 50 // Expect error. | 50 // Expect error. |
| 51 }); | |
| 52 })); | 51 })); |
| 53 } | 52 } |
| 54 Future.wait(futures).then((_) => server.close()); | 53 Future.wait(futures).then((_) => server.close()); |
| 55 }); | 54 }); |
| 56 } | 55 } |
| 57 | 56 |
| 58 void testDeadlineAndDetach(int connections) { | 57 void testDeadlineAndDetach(int connections) { |
| 59 HttpServer.bind('localhost', 0).then((server) { | 58 HttpServer.bind('localhost', 0).then((server) { |
| 60 server.listen((request) { | 59 server.listen((request) { |
| 61 request.response.deadline = const Duration(milliseconds: 0); | 60 request.response.deadline = const Duration(milliseconds: 0); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 84 Future.wait(futures).then((_) => server.close()); | 83 Future.wait(futures).then((_) => server.close()); |
| 85 }); | 84 }); |
| 86 } | 85 } |
| 87 | 86 |
| 88 void main() { | 87 void main() { |
| 89 testSimpleDeadline(10); | 88 testSimpleDeadline(10); |
| 90 testExceedDeadline(10); | 89 testExceedDeadline(10); |
| 91 testDeadlineAndDetach(10); | 90 testDeadlineAndDetach(10); |
| 92 } | 91 } |
| 93 | 92 |
| OLD | NEW |