| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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:isolate"; | 10 import "dart:isolate"; |
| 11 import "dart:io"; | 11 import "dart:io"; |
| 12 | 12 |
| 13 void main() { | 13 void main() { |
| 14 ReceivePort keepAlive = new ReceivePort(); | 14 ReceivePort keepAlive = new ReceivePort(); |
| 15 SecureSocket.initialize(); | 15 SecureSocket.initialize(); |
| 16 List<String> chunks = <String>[]; | 16 List<String> chunks = <String>[]; |
| 17 SecureSocket.connect("www.google.dk", 443).then((socket) { | 17 SecureSocket.connect("www.google.dk", 443).then((socket) { |
| 18 socket.add("GET / HTTP/1.0\r\nHost: www.google.dk\r\n\r\n".charCodes); | 18 socket.add("GET / HTTP/1.0\r\nHost: www.google.dk\r\n\r\n".codeUnits); |
| 19 socket.close(); | 19 socket.close(); |
| 20 socket.listen( | 20 socket.listen( |
| 21 (List<int> data) { | 21 (List<int> data) { |
| 22 var received = new String.fromCharCodes(data); | 22 var received = new String.fromCharCodes(data); |
| 23 chunks.add(received); | 23 chunks.add(received); |
| 24 }, | 24 }, |
| 25 onDone: () { | 25 onDone: () { |
| 26 String fullPage = chunks.join(); | 26 String fullPage = chunks.join(); |
| 27 Expect.isTrue(fullPage.contains('</body></html>')); | 27 Expect.isTrue(fullPage.contains('</body></html>')); |
| 28 keepAlive.close(); | 28 keepAlive.close(); |
| 29 }, | 29 }, |
| 30 onError: (e) => Expect.fail("Unexpected error $e")); | 30 onError: (e) => Expect.fail("Unexpected error $e")); |
| 31 }); | 31 }); |
| 32 } | 32 } |
| OLD | NEW |