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"; |
11 import "package:path/path.dart"; | 11 import "package:path/path.dart"; |
12 import "dart:async"; | 12 import "dart:async"; |
13 import "dart:io"; | 13 import "dart:io"; |
14 import "dart:isolate"; | 14 import "dart:isolate"; |
15 | 15 |
16 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 16 String localFile(path) => Platform.script.resolve(path).toFilePath(); |
17 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync(); | |
18 | 17 |
19 SecurityContext serverContext = new SecurityContext() | 18 SecurityContext serverContext = new SecurityContext() |
20 ..useCertificateChainBytes(readLocalFile('certificates/server_chain.pem')) | 19 ..useCertificateChainSync(localFile('certificates/server_chain.pem')) |
21 ..usePrivateKeyBytes(readLocalFile('certificates/server_key.pem'), | 20 ..usePrivateKeySync(localFile('certificates/server_key.pem'), |
22 password: 'dartdart'); | 21 password: 'dartdart'); |
23 | 22 |
24 SecurityContext clientContext = new SecurityContext() | 23 SecurityContext clientContext = new SecurityContext() |
25 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); | 24 ..setTrustedCertificatesSync(localFile('certificates/trusted_certs.pem')); |
26 | 25 |
27 Future<HttpServer> startServer() { | 26 Future<HttpServer> startServer() { |
28 return HttpServer.bindSecure( | 27 return HttpServer.bindSecure( |
29 "localhost", | 28 "localhost", |
30 0, | 29 0, |
31 serverContext, | 30 serverContext, |
32 backlog: 5).then((server) { | 31 backlog: 5).then((server) { |
33 server.listen((HttpRequest request) { | 32 server.listen((HttpRequest request) { |
34 request.listen( | 33 request.listen( |
35 (_) { }, | 34 (_) { }, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 106 } |
108 | 107 |
109 subscription = socket.listen( | 108 subscription = socket.listen( |
110 handleRawEvent, | 109 handleRawEvent, |
111 onError: (e, trace) { | 110 onError: (e, trace) { |
112 String msg = "onError handler of RawSecureSocket stream hit: $e"; | 111 String msg = "onError handler of RawSecureSocket stream hit: $e"; |
113 if (trace != null) msg += "\nStackTrace: $trace"; | 112 if (trace != null) msg += "\nStackTrace: $trace"; |
114 Expect.fail(msg); | 113 Expect.fail(msg); |
115 }); | 114 }); |
116 } | 115 } |
OLD | NEW |