Chromium Code Reviews| 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 // Regression test for http://code.google.com/p/dart/issues/detail?id=6393. | 5 // Regression test for http://code.google.com/p/dart/issues/detail?id=6393. |
| 6 | 6 |
| 7 import "dart:async"; | |
|
Søren Gjesse
2013/04/09 10:44:35
Maybe just remove this test.
Anders Johnsen
2013/04/09 10:48:42
Done.
| |
| 7 import "dart:io"; | 8 import "dart:io"; |
| 8 import "dart:uri"; | 9 import "dart:uri"; |
| 9 | 10 |
| 10 var client = new HttpClient(); | 11 var client = new HttpClient(); |
| 11 var clientRequest; | 12 var clientRequest; |
| 12 | 13 |
| 13 void main() { | 14 void main() { |
| 14 HttpServer.bind("127.0.0.1", 0) | 15 HttpServer.bind("127.0.0.1", 0) |
| 15 .then((server) { | 16 .then((server) { |
| 16 server.listen( | 17 server.listen( |
| 17 (req) { | 18 (req) { |
| 18 req.pipe(req.response); | 19 req.pipe(req.response); |
| 19 }); | 20 }); |
| 20 | 21 |
| 21 client.openUrl("POST", Uri.parse("http://localhost:${server.port}/")) | 22 client.openUrl("POST", Uri.parse("http://localhost:${server.port}/")) |
| 22 .then((request) { | 23 .then((request) { |
| 23 // Keep a reference to the client request object. | 24 // Keep a reference to the client request object. |
| 24 clientRequest = request; | 25 clientRequest = request; |
| 25 request.writeBytes([0]); | 26 request.writeBytes([0]); |
| 27 new Timer(const Duration(milliseconds: 200), () { | |
| 28 server.close(); | |
| 29 client.close(); | |
| 30 }); | |
| 26 return request.response; | 31 return request.response; |
| 27 }) | 32 }) |
| 28 .then((response) { | 33 .then((response) { |
| 29 // Wait with closing the client request until the response headers | 34 Expect.fail("Unexpected response"); |
| 30 // are done. | |
| 31 clientRequest.close(); | |
| 32 response.listen( | |
| 33 (_) {}, | |
| 34 onDone: () { | |
| 35 client.close(); | |
| 36 server.close(); | |
| 37 }); | |
| 38 }); | 35 }); |
| 39 }); | 36 }); |
| 40 } | 37 } |
| OLD | NEW |