| 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(); |
| 26 | 27 |
| 27 SecurityContext serverContext = new SecurityContext() | 28 SecurityContext serverContext = new SecurityContext() |
| 28 ..useCertificateChain(localFile('certificates/server_chain.pem')) | 29 ..useCertificateChain(localFile('certificates/server_chain.pem')) |
| 29 ..usePrivateKey(localFile('certificates/server_key.pem'), | 30 ..usePrivateKeyAsBytes(readLocalFile('certificates/server_key.pem'), |
| 30 password: 'dartdart'); | 31 password: 'dartdart'); |
| 31 | 32 |
| 32 class SecurityConfiguration { | 33 class SecurityConfiguration { |
| 33 final bool secure; | 34 final bool secure; |
| 34 | 35 |
| 35 SecurityConfiguration({bool this.secure}); | 36 SecurityConfiguration({bool this.secure}); |
| 36 | 37 |
| 37 Future<HttpServer> createServer({int backlog: 0}) => | 38 Future<HttpServer> createServer({int backlog: 0}) => |
| 38 secure ? HttpServer.bindSecure(HOST_NAME, | 39 secure ? HttpServer.bindSecure(HOST_NAME, |
| 39 0, | 40 0, |
| 40 serverContext, | 41 serverContext, |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 serverMaxWindowBits: 8); | 377 serverMaxWindowBits: 8); |
| 377 testClientRequestHeaders(compression); | 378 testClientRequestHeaders(compression); |
| 378 } | 379 } |
| 379 } | 380 } |
| 380 | 381 |
| 381 main() { | 382 main() { |
| 382 new SecurityConfiguration(secure: false).runTests(); | 383 new SecurityConfiguration(secure: false).runTests(); |
| 383 // TODO(whesse): Make WebSocket.connect() take an optional context: parameter. | 384 // TODO(whesse): Make WebSocket.connect() take an optional context: parameter. |
| 384 // new SecurityConfiguration(secure: true).runTests(); | 385 // new SecurityConfiguration(secure: true).runTests(); |
| 385 } | 386 } |
| OLD | NEW |