| 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:convert"; | 11 import "dart:convert"; |
| 12 import "dart:io"; | 12 import "dart:io"; |
| 13 import "dart:typed_data"; | 13 import "dart:typed_data"; |
| 14 import "dart:math"; | 14 import "dart:math"; |
| 15 | 15 |
| 16 import "package:async_helper/async_helper.dart"; | 16 import "package:async_helper/async_helper.dart"; |
| 17 import "package:crypto/crypto.dart"; | 17 import "package:crypto/crypto.dart"; |
| 18 import "package:expect/expect.dart"; | 18 import "package:expect/expect.dart"; |
| 19 import "package:path/path.dart"; | 19 import "package:path/path.dart"; |
| 20 | 20 |
| 21 const WEB_SOCKET_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; | 21 const WEB_SOCKET_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; |
| 22 | 22 |
| 23 const String HOST_NAME = 'localhost'; | 23 const String HOST_NAME = 'localhost'; |
| 24 | 24 |
| 25 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 25 String localFile(path) => Platform.script.resolve(path).toFilePath(); |
| 26 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync(); | |
| 27 | 26 |
| 28 SecurityContext serverContext = new SecurityContext() | 27 SecurityContext serverContext = new SecurityContext() |
| 29 ..useCertificateChainBytes(readLocalFile('certificates/server_chain.pem')) | 28 ..useCertificateChainSync(localFile('certificates/server_chain.pem')) |
| 30 ..usePrivateKeyBytes(readLocalFile('certificates/server_key.pem'), | 29 ..usePrivateKeySync(localFile('certificates/server_key.pem'), |
| 31 password: 'dartdart'); | 30 password: 'dartdart'); |
| 32 | 31 |
| 33 class SecurityConfiguration { | 32 class SecurityConfiguration { |
| 34 final bool secure; | 33 final bool secure; |
| 35 | 34 |
| 36 SecurityConfiguration({bool this.secure}); | 35 SecurityConfiguration({bool this.secure}); |
| 37 | 36 |
| 38 Future<HttpServer> createServer({int backlog: 0}) => | 37 Future<HttpServer> createServer({int backlog: 0}) => |
| 39 secure ? HttpServer.bindSecure(HOST_NAME, | 38 secure ? HttpServer.bindSecure(HOST_NAME, |
| 40 0, | 39 0, |
| 41 serverContext, | 40 serverContext, |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 serverMaxWindowBits: 8); | 376 serverMaxWindowBits: 8); |
| 378 testClientRequestHeaders(compression); | 377 testClientRequestHeaders(compression); |
| 379 } | 378 } |
| 380 } | 379 } |
| 381 | 380 |
| 382 main() { | 381 main() { |
| 383 new SecurityConfiguration(secure: false).runTests(); | 382 new SecurityConfiguration(secure: false).runTests(); |
| 384 // TODO(whesse): Make WebSocket.connect() take an optional context: parameter. | 383 // TODO(whesse): Make WebSocket.connect() take an optional context: parameter. |
| 385 // new SecurityConfiguration(secure: true).runTests(); | 384 // new SecurityConfiguration(secure: true).runTests(); |
| 386 } | 385 } |
| OLD | NEW |