| 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 "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 void testClientDetachSocket() { | 71 void testClientDetachSocket() { |
| 72 ServerSocket.bind("127.0.0.1", 0).then((server) { | 72 ServerSocket.bind("127.0.0.1", 0).then((server) { |
| 73 server.listen((socket) { | 73 server.listen((socket) { |
| 74 socket.write("HTTP/1.1 200 OK\r\n" | 74 socket.write("HTTP/1.1 200 OK\r\n" |
| 75 "\r\n" | 75 "\r\n" |
| 76 "Test!"); | 76 "Test!"); |
| 77 var body = new StringBuffer(); | 77 var body = new StringBuffer(); |
| 78 socket.listen( | 78 socket.listen( |
| 79 (data) => body.write(new String.fromCharCodes(data)), | 79 (data) => body.write(new String.fromCharCodes(data)), |
| 80 onDone: () { | 80 onDone: () { |
| 81 Expect.equals("GET / HTTP/1.1\r\n" | 81 List<String> lines = body.toString().split("\r\n"); |
| 82 "accept-encoding: gzip\r\n" | 82 Expect.equals(6, lines.length); |
| 83 "content-length: 0\r\n" | 83 Expect.equals("GET / HTTP/1.1", lines[0]); |
| 84 "host: 127.0.0.1:${server.port}\r\n\r\n" | 84 Expect.equals("", lines[4]); |
| 85 "Some data", | 85 Expect.equals("Some data", lines[5]); |
| 86 body.toString()); | 86 lines.sort(); // Lines 1-3 becomes 3-5 in a fixed order. |
| 87 Expect.equals("accept-encoding: gzip", lines[3]); |
| 88 Expect.equals("content-length: 0", lines[4]); |
| 89 Expect.equals("host: 127.0.0.1:${server.port}", lines[5]); |
| 87 socket.close(); | 90 socket.close(); |
| 88 }); | 91 }); |
| 89 server.close(); | 92 server.close(); |
| 90 }); | 93 }); |
| 91 | 94 |
| 92 var client = new HttpClient(); | 95 var client = new HttpClient(); |
| 93 client.userAgent = null; | 96 client.userAgent = null; |
| 94 client.get("127.0.0.1", server.port, "/") | 97 client.get("127.0.0.1", server.port, "/") |
| 95 .then((request) => request.close()) | 98 .then((request) => request.close()) |
| 96 .then((response) { | 99 .then((response) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 108 }); | 111 }); |
| 109 }); | 112 }); |
| 110 }); | 113 }); |
| 111 } | 114 } |
| 112 | 115 |
| 113 void main() { | 116 void main() { |
| 114 testServerDetachSocket(); | 117 testServerDetachSocket(); |
| 115 testBadServerDetachSocket(); | 118 testBadServerDetachSocket(); |
| 116 testClientDetachSocket(); | 119 testClientDetachSocket(); |
| 117 } | 120 } |
| OLD | NEW |