Index: tests/standalone/io/tls_socket_test.dart |
diff --git a/tests/standalone/io/tls_socket_test.dart b/tests/standalone/io/tls_socket_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8dae1666a3480b75aa7f385c54a2805f4fa39740 |
--- /dev/null |
+++ b/tests/standalone/io/tls_socket_test.dart |
@@ -0,0 +1,39 @@ |
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+// |
+// VMOptions= |
+// VMOptions=--short_socket_read |
Søren Gjesse
2012/11/12 12:04:57
How about --short_socket_write and both --short_so
Bill Hesse
2012/11/13 20:11:08
Comment added - TODO below explains why these don'
|
+ |
+#import("dart:isolate"); |
+#import("dart:io"); |
+ |
+void main() { |
+ var testPkcertDatabase = |
+ new Path.fromNative(new Options().script).directoryPath.append('pkcert/'); |
Mads Ager (google)
2012/11/12 11:39:08
I still don't see a pkcert directory in this chang
Bill Hesse
2012/11/13 20:11:08
Added.
On 2012/11/12 11:39:08, Mads Ager wrote:
|
+ TlsSocket.setCertificateDatabase(testPkcertDatabase.toNativePath()); |
+ // TODO(3593): Use a Dart HTTPS server for this test using TLS server sockets. |
+ // When we use a Dart HTTPS server, allow --short_socket_write. The flag |
+ // causes fragmentation of the client hello message, which doesn't seem to |
+ // work with www.google.dk. |
+ var tls = new TlsSocket("www.google.dk", 443); |
+ List<String> chunks = <String>[]; |
+ tls.onConnect = () { |
+ var request_bytes = |
+ "GET / HTTP/1.0\r\nHost: www.google.dk\r\n\r\n".charCodes; |
+ tls.writeList(request_bytes, 0, 20); |
+ tls.writeList(request_bytes, 20, request_bytes.length - 20); |
+ }; |
+ tls.onData = () { |
+ var buffer = new List(2000); |
+ int len = tls.readList(buffer, 0, 2000); |
+ var received = new String.fromCharCodes(buffer.getRange(0, len)); |
+ chunks.add(received); |
+ }; |
+ tls.onClosed = () { |
+ String fullPage = Strings.concatAll(chunks); |
+ print(fullPage); |
Mads Ager (google)
2012/11/12 11:39:08
Remove the print. Not sure it is usefully to get g
Bill Hesse
2012/11/13 20:11:08
Done.
|
+ Expect.isTrue(fullPage.contains('</body></html>')); |
+ tls.close(); |
+ }; |
+} |