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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 request.response.contentLength = 5; | 236 request.response.contentLength = 5; |
237 request.response.add([0]); | 237 request.response.add([0]); |
238 request.response.close(); | 238 request.response.close(); |
239 request.response.done.catchError((error) { | 239 request.response.done.catchError((error) { |
240 server.close(); | 240 server.close(); |
241 }, test: (e) => e is HttpException); | 241 }, test: (e) => e is HttpException); |
242 }); | 242 }); |
243 } | 243 } |
244 | 244 |
245 | 245 |
| 246 void testIgnoreRequestData() { |
| 247 HttpServer.bind("127.0.0.1", 0) |
| 248 .then((server) { |
| 249 server.listen((request) { |
| 250 // Ignore request data. |
| 251 request.response.write("all-okay"); |
| 252 request.response.close(); |
| 253 }); |
| 254 |
| 255 var client = new HttpClient(); |
| 256 client.get("127.0.0.1", server.port, "/") |
| 257 .then((request) { |
| 258 request.contentLength = 1024 * 1024; |
| 259 request.add(new Uint8List(1024 * 1024)); |
| 260 return request.close(); |
| 261 }) |
| 262 .then((response) { |
| 263 response |
| 264 .fold(0, (s, b) => s + b.length) |
| 265 .then((bytes) { |
| 266 Expect.equals(8, bytes); |
| 267 server.close(); |
| 268 }); |
| 269 }); |
| 270 }); |
| 271 } |
| 272 |
| 273 |
246 void main() { | 274 void main() { |
247 testResponseDone(); | 275 testResponseDone(); |
248 testResponseAddStream(); | 276 testResponseAddStream(); |
249 testResponseAddStreamClosed(); | 277 testResponseAddStreamClosed(); |
250 testResponseAddClosed(); | 278 testResponseAddClosed(); |
251 testBadResponseAdd(); | 279 testBadResponseAdd(); |
252 testBadResponseClose(); | 280 testBadResponseClose(); |
| 281 testIgnoreRequestData(); |
253 } | 282 } |
OLD | NEW |