| 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 library utils; | 5 library utils; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import "package:unittest/unittest.dart"; | 10 import "package:unittest/unittest.dart"; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 }); | 88 }); |
| 89 } | 89 } |
| 90 | 90 |
| 91 Future _withServer(Future func(HttpServer server)) { | 91 Future _withServer(Future func(HttpServer server)) { |
| 92 HttpServer server; | 92 HttpServer server; |
| 93 return HttpServer.bind('localhost', 0) | 93 return HttpServer.bind('localhost', 0) |
| 94 .then((value) { | 94 .then((value) { |
| 95 server = value; | 95 server = value; |
| 96 return func(server); | 96 return func(server); |
| 97 }) | 97 }) |
| 98 .whenComplete(server.close); | 98 .whenComplete(() => server.close()); |
| 99 } | 99 } |
| 100 | 100 |
| 101 | 101 |
| 102 const CERTIFICATE = "localhost_cert"; | 102 const CERTIFICATE = "localhost_cert"; |
| 103 | 103 |
| 104 | 104 |
| 105 void setupSecure() { | 105 void setupSecure() { |
| 106 String certificateDatabase = Platform.script.resolve('pkcert').toFilePath(); | 106 String certificateDatabase = Platform.script.resolve('pkcert').toFilePath(); |
| 107 SecureSocket.initialize(database: certificateDatabase, | 107 SecureSocket.initialize(database: certificateDatabase, |
| 108 password: 'dartdart'); | 108 password: 'dartdart'); |
| 109 } | 109 } |
| OLD | NEW |