| 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(); |
| 17 | 18 |
| 18 SecurityContext serverContext = new SecurityContext() | 19 SecurityContext serverContext = new SecurityContext() |
| 19 ..useCertificateChain(localFile('certificates/server_chain.pem')) | 20 ..useCertificateChain(localFile('certificates/server_chain.pem')) |
| 20 ..usePrivateKey(localFile('certificates/server_key.pem'), | 21 ..usePrivateKeyAsBytes(readLocalFile('certificates/server_key.pem'), |
| 21 password: 'dartdart'); | 22 password: 'dartdart'); |
| 22 | 23 |
| 23 SecurityContext clientContext = new SecurityContext() | 24 SecurityContext clientContext = new SecurityContext() |
| 24 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); | 25 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); |
| 25 | 26 |
| 26 main() async { | 27 main() async { |
| 27 List<int> message = "GET / HTTP/1.0\r\nHost: localhost\r\n\r\n".codeUnits; | 28 List<int> message = "GET / HTTP/1.0\r\nHost: localhost\r\n\r\n".codeUnits; |
| 28 int written = 0; | 29 int written = 0; |
| 29 List<int> body = <int>[]; | 30 List<int> body = <int>[]; |
| 30 var server = await HttpServer.bindSecure( | 31 var server = await HttpServer.bindSecure( |
| 31 "localhost", | 32 "localhost", |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 server.close(); | 65 server.close(); |
| 65 break; | 66 break; |
| 66 default: throw "Unexpected event $event"; | 67 default: throw "Unexpected event $event"; |
| 67 } | 68 } |
| 68 }, onError: (e, trace) { | 69 }, onError: (e, trace) { |
| 69 String msg = "onError handler of RawSecureSocket stream hit $e"; | 70 String msg = "onError handler of RawSecureSocket stream hit $e"; |
| 70 if (trace != null) msg += "\nStackTrace: $trace"; | 71 if (trace != null) msg += "\nStackTrace: $trace"; |
| 71 Expect.fail(msg); | 72 Expect.fail(msg); |
| 72 }); | 73 }); |
| 73 } | 74 } |
| OLD | NEW |