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"; |
11 import "dart:io"; | 11 import "dart:io"; |
12 | 12 |
13 import "package:async_helper/async_helper.dart"; | 13 import "package:async_helper/async_helper.dart"; |
14 import "package:expect/expect.dart"; | 14 import "package:expect/expect.dart"; |
15 | 15 |
16 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 16 String localFile(path) => Platform.script.resolve(path).toFilePath(); |
17 | 17 |
18 SecurityContext serverContext = new SecurityContext() | 18 SecurityContext serverContext = new SecurityContext() |
19 ..useCertificateChainSync(localFile('certificates/server_chain.pem')) | 19 ..useCertificateChain(localFile('certificates/server_chain.pem')) |
20 ..usePrivateKeySync(localFile('certificates/server_key.pem'), | 20 ..usePrivateKey(localFile('certificates/server_key.pem'), |
21 password: 'dartdart'); | 21 password: 'dartdart'); |
22 | 22 |
23 SecurityContext clientContext = new SecurityContext() | 23 SecurityContext clientContext = new SecurityContext() |
24 ..setTrustedCertificatesSync(localFile('certificates/trusted_certs.pem')); | 24 ..setTrustedCertificates(localFile('certificates/trusted_certs.pem')); |
25 | 25 |
26 InternetAddress HOST; | 26 InternetAddress HOST; |
27 Future<RawSecureServerSocket> startEchoServer() { | 27 Future<RawSecureServerSocket> startEchoServer() { |
28 return RawSecureServerSocket.bind(HOST, | 28 return RawSecureServerSocket.bind(HOST, |
29 0, | 29 0, |
30 serverContext).then((server) { | 30 serverContext).then((server) { |
31 server.listen((RawSecureSocket client) { | 31 server.listen((RawSecureSocket client) { |
32 List<List<int>> readChunks = <List<int>>[]; | 32 List<List<int>> readChunks = <List<int>>[]; |
33 List<int> dataToWrite = null; | 33 List<int> dataToWrite = null; |
34 int bytesWritten = 0; | 34 int bytesWritten = 0; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 } | 88 } |
89 | 89 |
90 void main() { | 90 void main() { |
91 asyncStart(); | 91 asyncStart(); |
92 InternetAddress.lookup("localhost").then((hosts) => HOST = hosts.first) | 92 InternetAddress.lookup("localhost").then((hosts) => HOST = hosts.first) |
93 .then((_) => startEchoServer()) | 93 .then((_) => startEchoServer()) |
94 .then(testClient) | 94 .then(testClient) |
95 .then((server) => server.close()) | 95 .then((server) => server.close()) |
96 .then((_) => asyncEnd()); | 96 .then((_) => asyncEnd()); |
97 } | 97 } |
OLD | NEW |