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

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

Issue 11819030: Add onClosed callbacks to HTTP output streams (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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..33aa8ec0dfba63489c538efbce8e7298d305c37f
--- /dev/null
+++ b/tests/standalone/io/http_stream_close_test.dart
@@ -0,0 +1,42 @@
+// 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.
+//
+
+import "dart:io";
+import "dart:uri";
+
+main() {
+ bool serverOnClosed = false;
+ bool clientOnClosed = false;
+
+ var server = new HttpServer();
+ 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;
+ response.outputStream.writeString("hello!");
+ response.outputStream.close();
+ };
+ };
+
+ var client = new HttpClient();
+ var connection = client.postUrl(new Uri.fromString("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;
+ request.outputStream.writeString("hello!");
+ request.outputStream.close();
+ };
+ connection.onResponse = (response) {
+ response.inputStream.onData = response.inputStream.read;
+ response.inputStream.onClosed = () {
+ Expect.isTrue(serverOnClosed && clientOnClosed);
+ server.close();
+ client.shutdown();
+ };
+ };
+}
« 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