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 15 matching lines...) Expand all Loading... |
26 (data) {}, | 26 (data) {}, |
27 onDone: server.close); | 27 onDone: server.close); |
28 }); | 28 }); |
29 }); | 29 }); |
30 } | 30 } |
31 | 31 |
32 void testGetDataRequest() { | 32 void testGetDataRequest() { |
33 HttpServer.bind().then((server) { | 33 HttpServer.bind().then((server) { |
34 var data = "lalala".codeUnits; | 34 var data = "lalala".codeUnits; |
35 server.listen((request) { | 35 server.listen((request) { |
36 request.response.writeBytes(data); | 36 request.response.add(data); |
37 request.pipe(request.response); | 37 request.pipe(request.response); |
38 }); | 38 }); |
39 | 39 |
40 var client = new HttpClient(); | 40 var client = new HttpClient(); |
41 client.get("127.0.0.1", server.port, "/") | 41 client.get("127.0.0.1", server.port, "/") |
42 .then((request) => request.close()) | 42 .then((request) => request.close()) |
43 .then((response) { | 43 .then((response) { |
44 int count = 0; | 44 int count = 0; |
45 response.listen( | 45 response.listen( |
46 (data) => count += data.length, | 46 (data) => count += data.length, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 126 |
127 | 127 |
128 void main() { | 128 void main() { |
129 testGetEmptyRequest(); | 129 testGetEmptyRequest(); |
130 testGetDataRequest(); | 130 testGetDataRequest(); |
131 testGetInvalidHost(); | 131 testGetInvalidHost(); |
132 testGetServerClose(); | 132 testGetServerClose(); |
133 testGetDataServerClose(); | 133 testGetDataServerClose(); |
134 testPostEmptyRequest(); | 134 testPostEmptyRequest(); |
135 } | 135 } |
OLD | NEW |