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

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

Issue 11853011: Reapply "Add onClosed callbacks to HTTP output streams"" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed debug print Created 7 years, 11 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 | « sdk/lib/io/http_impl.dart ('k') | no next file » | 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
new file mode 100644
index 0000000000000000000000000000000000000000..1f6d65b21161cc2bac53bf44cb179109c4834d4f
--- /dev/null
+++ b/tests/standalone/io/http_stream_close_test.dart
@@ -0,0 +1,56 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+//
Mads Ager (google) 2013/01/11 12:09:12 Remove this line?
+
+import "dart:io";
+import "dart:uri";
+
+main() {
+ bool serverOnClosed = false;
+ bool clientOnClosed = false;
+ bool requestOnClosed = false;
+
+ var server = new HttpServer();
+ var client = new HttpClient();
+
+ checkDone() {
+ if (serverOnClosed && clientOnClosed && requestOnClosed) {
+ server.close();
+ client.shutdown();
+ }
+ }
+
+ 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();
+ };
+ };
+
+ var connection = client.postUrl(new Uri.fromString("http://127.0.0.1:${server.port}"));
Mads Ager (google) 2013/01/11 12:09:12 Line line.
+ 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();
+ };
+ };
+}
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698