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

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

Issue 12385048: Support canceling an incoming message, while the other end will be notified (by write-error from th… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 | « sdk/lib/io/http_parser.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_close_test.dart
diff --git a/tests/standalone/io/http_close_test.dart b/tests/standalone/io/http_close_test.dart
index f882856df18134fc6016b0d811ef585c0a6ecc5b..de467d5ae46eb727b91b383c00bf84b14cb1d50a 100644
--- a/tests/standalone/io/http_close_test.dart
+++ b/tests/standalone/io/http_close_test.dart
@@ -109,9 +109,52 @@ void testClientCloseDelayed(int connections) {
}
+void testClientCloseSendingResponse(int connections) {
+ HttpServer.bind().then((server) {
+ int closed = 0;
+ void check() {
+ closed++;
+ // Wait for both server and client to see the connections as closed.
+ if (closed == connections * 2) {
+ Expect.equals(0, server.connectionsInfo().active);
+ Expect.equals(server.connectionsInfo().total,
+ server.connectionsInfo().idle);
+ server.close();
+ }
+ }
+ server.listen((request) {
+ var timer = new Timer.repeating(const Duration(milliseconds: 20), (_) {
+ request.response.add(new Uint8List(16 * 1024));
+ });
+ request.response.done
+ .catchError((_) {})
+ .whenComplete(() {
+ check();
+ timer.cancel();
+ });
+ });
+ var client = new HttpClient();
+ for (int i = 0; i < connections; i++) {
+ client.get("localhost", server.port, "/")
+ .then((request) => request.close())
+ .then((response) {
+ // Ensure we don't accept the response until we have send the entire
+ // request.
+ var subscription = response.listen((_) {});
+ new Timer(const Duration(milliseconds: 200), () {
+ subscription.cancel();
+ check();
+ });
+ });
+ }
+ });
+}
+
+
void main() {
testClientAndServerCloseNoListen(10);
testClientCloseServerListen(10);
testClientCloseDelayed(10);
+ testClientCloseSendingResponse(10);
}
« no previous file with comments | « sdk/lib/io/http_parser.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698