| 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:crypto/crypto.dart"; | 5 import "package:crypto/crypto.dart"; |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 import "package:path/path.dart"; | 7 import "package:path/path.dart"; |
| 8 import "dart:async"; | 8 import "dart:async"; |
| 9 import "dart:io"; | 9 import "dart:io"; |
| 10 import 'dart:convert'; | 10 import 'dart:convert'; |
| 11 | 11 |
| 12 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 12 String localFile(path) => Platform.script.resolve(path).toFilePath(); |
| 13 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync(); | 13 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync(); |
| 14 | 14 |
| 15 SecurityContext serverContext = new SecurityContext() | 15 SecurityContext serverContext = new SecurityContext() |
| 16 ..useCertificateChainBytes(readLocalFile('certificates/server_chain.pem')) | 16 ..useCertificateChainBytes(readLocalFile('certificates/server_chain.pem')) |
| 17 ..usePrivateKeyBytes(readLocalFile('certificates/server_key.pem'), | 17 ..usePrivateKeyBytes(readLocalFile('certificates/server_key.pem'), |
| 18 password: 'dartdart'); | 18 password: 'dartdart'); |
| 19 | 19 |
| 20 SecurityContext clientContext = new SecurityContext() | 20 SecurityContext clientContext = new SecurityContext() |
| 21 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); | 21 ..setTrustedCertificatesBytes( |
| 22 readLocalFile('certificates/trusted_certs.pem')); |
| 22 | 23 |
| 23 class Server { | 24 class Server { |
| 24 HttpServer server; | 25 HttpServer server; |
| 25 bool secure; | 26 bool secure; |
| 26 int proxyHops; | 27 int proxyHops; |
| 27 List<String> directRequestPaths; | 28 List<String> directRequestPaths; |
| 28 int requestCount = 0; | 29 int requestCount = 0; |
| 29 | 30 |
| 30 Server(this.proxyHops, this.directRequestPaths, this.secure); | 31 Server(this.proxyHops, this.directRequestPaths, this.secure); |
| 31 | 32 |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 }); | 471 }); |
| 471 }); | 472 }); |
| 472 } | 473 } |
| 473 | 474 |
| 474 main() { | 475 main() { |
| 475 testInvalidProxy(); | 476 testInvalidProxy(); |
| 476 testDirectProxy(); | 477 testDirectProxy(); |
| 477 testProxy(); | 478 testProxy(); |
| 478 testProxyChain(); | 479 testProxyChain(); |
| 479 } | 480 } |
| OLD | NEW |