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