| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 new Timer(const Duration(milliseconds: 200), () { | 104 new Timer(const Duration(milliseconds: 200), () { |
| 105 subscription.cancel(); | 105 subscription.cancel(); |
| 106 check(); | 106 check(); |
| 107 }); | 107 }); |
| 108 }); | 108 }); |
| 109 } | 109 } |
| 110 }); | 110 }); |
| 111 } | 111 } |
| 112 | 112 |
| 113 | 113 |
| 114 void testClientCloseWhileSendingRequest(int connections) { |
| 115 HttpServer.bind("127.0.0.1", 0).then((server) { |
| 116 int errors = 0; |
| 117 server.listen((request) { |
| 118 request.listen((_) {}, onError: (e) { errors++; }); |
| 119 }); |
| 120 var client = new HttpClient(); |
| 121 for (int i = 0; i < connections; i++) { |
| 122 client.post("127.0.0.1", server.port, "/") |
| 123 .then((request) { |
| 124 request.contentLength = 110; |
| 125 request.write("0123456789"); |
| 126 return request.close(); |
| 127 }) |
| 128 .catchError((_) {}); |
| 129 } |
| 130 new Timer.periodic(const Duration(milliseconds: 100), (t) { |
| 131 if (errors == connections && server.connectionsInfo().total == 0) { |
| 132 t.cancel(); |
| 133 server.close(); |
| 134 } |
| 135 }); |
| 136 }); |
| 137 } |
| 138 |
| 139 |
| 114 void main() { | 140 void main() { |
| 115 testClientAndServerCloseNoListen(10); | 141 testClientAndServerCloseNoListen(10); |
| 116 testClientCloseServerListen(10); | 142 testClientCloseServerListen(10); |
| 117 testClientCloseSendingResponse(10); | 143 testClientCloseSendingResponse(10); |
| 144 testClientCloseWhileSendingRequest(10); |
| 118 } | 145 } |
| 119 | 146 |
| OLD | NEW |