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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/http_parser.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 8 // VMOptions=--short_socket_read --short_socket_write
9 9
10 import "dart:async"; 10 import "dart:async";
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 (_) {}, 102 (_) {},
103 onDone: () { 103 onDone: () {
104 check(); 104 check();
105 }); 105 });
106 }); 106 });
107 } 107 }
108 }); 108 });
109 } 109 }
110 110
111 111
112 void testClientCloseSendingResponse(int connections) {
113 HttpServer.bind().then((server) {
114 int closed = 0;
115 void check() {
116 closed++;
117 // Wait for both server and client to see the connections as closed.
118 if (closed == connections * 2) {
119 Expect.equals(0, server.connectionsInfo().active);
120 Expect.equals(server.connectionsInfo().total,
121 server.connectionsInfo().idle);
122 server.close();
123 }
124 }
125 server.listen((request) {
126 var timer = new Timer.repeating(const Duration(milliseconds: 20), (_) {
127 request.response.add(new Uint8List(16 * 1024));
128 });
129 request.response.done
130 .catchError((_) {})
131 .whenComplete(() {
132 check();
133 timer.cancel();
134 });
135 });
136 var client = new HttpClient();
137 for (int i = 0; i < connections; i++) {
138 client.get("localhost", server.port, "/")
139 .then((request) => request.close())
140 .then((response) {
141 // Ensure we don't accept the response until we have send the entire
142 // request.
143 var subscription = response.listen((_) {});
144 new Timer(const Duration(milliseconds: 200), () {
145 subscription.cancel();
146 check();
147 });
148 });
149 }
150 });
151 }
152
153
112 void main() { 154 void main() {
113 testClientAndServerCloseNoListen(10); 155 testClientAndServerCloseNoListen(10);
114 testClientCloseServerListen(10); 156 testClientCloseServerListen(10);
115 testClientCloseDelayed(10); 157 testClientCloseDelayed(10);
158 testClientCloseSendingResponse(10);
116 } 159 }
117 160
OLDNEW
« 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