Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: tests/standalone/io/http_stream_close_test.dart

Issue 12316036: Merge IO v2 branch to bleeding edge (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r18818 Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/standalone/io/http_shutdown_test.dart ('k') | tests/standalone/io/https_client_certificate_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/http_stream_close_test.dart
diff --git a/tests/standalone/io/http_stream_close_test.dart b/tests/standalone/io/http_stream_close_test.dart
index 9f444a659c9d0873984cf9eb940a16b1667ac492..6cf73d6ef3d86176d554ed5f4b690d4f4bb6b611 100644
--- a/tests/standalone/io/http_stream_close_test.dart
+++ b/tests/standalone/io/http_stream_close_test.dart
@@ -11,47 +11,46 @@ main() {
bool clientOnClosed = false;
bool requestOnClosed = false;
- var server = new HttpServer();
- var client = new HttpClient();
+ HttpServer.bind("127.0.0.1", 0).then((server) {
+ var client = new HttpClient();
- checkDone() {
- if (serverOnClosed && clientOnClosed && requestOnClosed) {
- server.close();
- client.shutdown();
+ checkDone() {
+ if (serverOnClosed && clientOnClosed && requestOnClosed) {
+ server.close();
+ client.close();
+ }
}
- }
- server.listen("127.0.0.1", 0);
- server.defaultRequestHandler = (request, response) {
- request.inputStream.onData = request.inputStream.read;
- request.inputStream.onClosed = () {
- response.outputStream.onClosed = () {
- serverOnClosed = true;
- checkDone();
- };
- response.outputStream.writeString("hello!");
- response.outputStream.close();
- };
- };
+ server.listen((request) {
+ request.listen(
+ (_) {},
+ onDone: () {
+ request.response.done.then((_) {
+ serverOnClosed = true;
+ checkDone();
+ });
+ request.response.addString("hello!");
+ request.response.close();
+ });
+ });
- var connection = client.postUrl(
- Uri.parse("http://127.0.0.1:${server.port}"));
- connection.onError = (e) { throw e; };
- connection.onRequest = (request) {
- request.contentLength = "hello!".length;
- request.outputStream.onError = (e) { throw e; };
- request.outputStream.onClosed = () {
- clientOnClosed = true;
- checkDone();
- };
- request.outputStream.writeString("hello!");
- request.outputStream.close();
- };
- connection.onResponse = (response) {
- response.inputStream.onData = response.inputStream.read;
- response.inputStream.onClosed = () {
- requestOnClosed = true;
- checkDone();
- };
- };
+ client.postUrl(Uri.parse("http://127.0.0.1:${server.port}"))
+ .then((request) {
+ request.contentLength = "hello!".length;
+ request.done.then((_) {
+ clientOnClosed = true;
+ checkDone();
+ });
+ request.addString("hello!");
+ return request.close();
+ })
+ .then((response) {
+ response.listen(
+ (_) {},
+ onDone: () {
+ requestOnClosed = true;
+ checkDone();
+ });
+ });
+ });
}
« no previous file with comments | « tests/standalone/io/http_shutdown_test.dart ('k') | tests/standalone/io/https_client_certificate_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698