| 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 const SESSION_ID = "DARTSESSID"; | 9 const SESSION_ID = "DARTSESSID"; |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 Expect.setEquals(new Set.from(clientSessions), sessions); | 61 Expect.setEquals(new Set.from(clientSessions), sessions); |
| 62 server.close(); | 62 server.close(); |
| 63 client.close(); | 63 client.close(); |
| 64 }); | 64 }); |
| 65 }); | 65 }); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void testTimeout(int sessionCount) { | 68 void testTimeout(int sessionCount) { |
| 69 var client = new HttpClient(); | 69 var client = new HttpClient(); |
| 70 HttpServer.bind("127.0.0.1", 0).then((server) { | 70 HttpServer.bind("127.0.0.1", 0).then((server) { |
| 71 server.sessionTimeout = 0; | 71 server.sessionTimeout = 1; |
| 72 var timeouts = []; | 72 var timeouts = []; |
| 73 server.listen((request) { | 73 server.listen((request) { |
| 74 var c = new Completer(); | 74 var c = new Completer(); |
| 75 timeouts.add(c.future); | 75 timeouts.add(c.future); |
| 76 request.session.onTimeout = () { | 76 request.session.onTimeout = () { |
| 77 c.complete(null); | 77 c.complete(null); |
| 78 }; | 78 }; |
| 79 request.response.close(); | 79 request.response.close(); |
| 80 }); | 80 }); |
| 81 | 81 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 }); | 191 }); |
| 192 }); | 192 }); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void main() { | 195 void main() { |
| 196 testSessions(1); | 196 testSessions(1); |
| 197 testTimeout(5); | 197 testTimeout(5); |
| 198 testSessionsData(); | 198 testSessionsData(); |
| 199 testSessionsDestroy(); | 199 testSessionsDestroy(); |
| 200 } | 200 } |
| OLD | NEW |