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 "dart:async"; | 10 import "dart:async"; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 }); | 114 }); |
115 } | 115 } |
116 | 116 |
117 | 117 |
118 void test4() { | 118 void test4() { |
119 HttpServer.bind().then((server) { | 119 HttpServer.bind().then((server) { |
120 | 120 |
121 server.listen((var request) { | 121 server.listen((var request) { |
122 request.listen((_) {}, onDone: () { | 122 request.listen((_) {}, onDone: () { |
123 new Timer.repeating(new Duration(milliseconds: 100), (timer) { | 123 new Timer.periodic(new Duration(milliseconds: 100), (timer) { |
124 if (server.connectionsInfo().total == 0) { | 124 if (server.connectionsInfo().total == 0) { |
125 server.close(); | 125 server.close(); |
126 timer.cancel(); | 126 timer.cancel(); |
127 } | 127 } |
128 }); | 128 }); |
129 request.response.close(); | 129 request.response.close(); |
130 }); | 130 }); |
131 }); | 131 }); |
132 | 132 |
133 var client= new HttpClient(); | 133 var client= new HttpClient(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // TODO(sgjesse): Make this test work with | 168 // TODO(sgjesse): Make this test work with |
169 //request.response instead of request.close() return | 169 //request.response instead of request.close() return |
170 //return request.response; | 170 //return request.response; |
171 request.done.catchError((e) {}); | 171 request.done.catchError((e) {}); |
172 return request.close(); | 172 return request.close(); |
173 }) | 173 }) |
174 .then((response) { }) | 174 .then((response) { }) |
175 .catchError((e) { }, test: (e) => e is HttpParserException); | 175 .catchError((e) { }, test: (e) => e is HttpParserException); |
176 } | 176 } |
177 bool clientClosed = false; | 177 bool clientClosed = false; |
178 new Timer.repeating(new Duration(milliseconds: 100), (timer) { | 178 new Timer.periodic(new Duration(milliseconds: 100), (timer) { |
179 if (!clientClosed) { | 179 if (!clientClosed) { |
180 if (server.connectionsInfo().total == totalConnections) { | 180 if (server.connectionsInfo().total == totalConnections) { |
181 clientClosed = true; | 181 clientClosed = true; |
182 client.close(force: true); | 182 client.close(force: true); |
183 } | 183 } |
184 } else { | 184 } else { |
185 if (server.connectionsInfo().total == 0) { | 185 if (server.connectionsInfo().total == 0) { |
186 server.close(); | 186 server.close(); |
187 timer.cancel(); | 187 timer.cancel(); |
188 } | 188 } |
189 } | 189 } |
190 }); | 190 }); |
191 }); | 191 }); |
192 } | 192 } |
193 | 193 |
194 | 194 |
195 void main() { | 195 void main() { |
196 test1(1); | 196 test1(1); |
197 test1(10); | 197 test1(10); |
198 test2(1, 10); | 198 test2(1, 10); |
199 test2(10, 10); | 199 test2(10, 10); |
200 test2(10, 1000); | 200 test2(10, 1000); |
201 test3(1); | 201 test3(1); |
202 test3(10); | 202 test3(10); |
203 test4(); | 203 test4(); |
204 test5(1); | 204 test5(1); |
205 test5(10); | 205 test5(10); |
206 } | 206 } |
OLD | NEW |