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

Side by Side Diff: tests/standalone/io/http_shutdown_test.dart

Issue 12317147: Implement addStream for HttpClientRequest/HttpResponse and propegate all write-errors from the sock… (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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 int count = 0; 47 int count = 0;
48 HttpClient client = new HttpClient(); 48 HttpClient client = new HttpClient();
49 for (int i = 0; i < totalConnections; i++) { 49 for (int i = 0; i < totalConnections; i++) {
50 client.get("127.0.0.1", server.port, "/") 50 client.get("127.0.0.1", server.port, "/")
51 .then((HttpClientRequest request) { 51 .then((HttpClientRequest request) {
52 request.contentLength = -1; 52 request.contentLength = -1;
53 for (int i = 0; i < outputStreamWrites; i++) { 53 for (int i = 0; i < outputStreamWrites; i++) {
54 request.addString("Hello, world!"); 54 request.addString("Hello, world!");
55 } 55 }
56 request.done.catchError((_) {});
Søren Gjesse 2013/02/27 15:07:43 I think we should add default handling of this so
Anders Johnsen 2013/02/28 11:39:02 Yes, we need to decide on what should happen on th
56 return request.close(); 57 return request.close();
57 }) 58 })
58 .then((HttpClientResponse response) { 59 .then((HttpClientResponse response) {
59 response.listen( 60 response.listen(
60 (_) {}, 61 (_) {},
61 onDone: () { 62 onDone: () {
62 count++; 63 count++;
63 if (count == totalConnections) { 64 if (count == totalConnections) {
64 client.close(force: true); 65 client.close(force: true);
65 server.close(); 66 server.close();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 144
144 145
145 void test5(int totalConnections) { 146 void test5(int totalConnections) {
146 HttpServer.bind().then((server) { 147 HttpServer.bind().then((server) {
147 server.listen( 148 server.listen(
148 (request) { 149 (request) {
149 request.listen( 150 request.listen(
150 (_) { }, 151 (_) { },
151 onDone: () { 152 onDone: () {
152 request.response.close(); 153 request.response.close();
154 request.response.done.catchError((e) {});
153 }, 155 },
154 onError: (error) { }); 156 onError: (error) { });
155 }, 157 },
156 onError: (error) { }); 158 onError: (error) { });
157 159
158 // Create a number of client requests and keep then active. Then 160 // Create a number of client requests and keep then active. Then
159 // close the client and wait for the server to lose all active 161 // close the client and wait for the server to lose all active
160 // connections. 162 // connections.
161 var client= new HttpClient(); 163 var client= new HttpClient();
162 for (int i = 0; i < totalConnections; i++) { 164 for (int i = 0; i < totalConnections; i++) {
163 client.post("127.0.0.1", server.port, "/") 165 client.post("127.0.0.1", server.port, "/")
164 .then((request) { 166 .then((request) {
165 request.add([0]); 167 request.add([0]);
166 // TODO(sgjesse): Make this test work with 168 // TODO(sgjesse): Make this test work with
167 //request.response instead of request.close() return 169 //request.response instead of request.close() return
168 //return request.response; 170 //return request.response;
171 request.done.catchError((e) {});
169 return request.close(); 172 return request.close();
170 }) 173 })
171 .then((response) { }) 174 .then((response) { })
172 .catchError((e) { }, test: (e) => e is HttpParserException); 175 .catchError((e) { }, test: (e) => e is HttpParserException);
173 } 176 }
174 bool clientClosed = false; 177 bool clientClosed = false;
175 new Timer.repeating(new Duration(milliseconds: 100), (timer) { 178 new Timer.repeating(new Duration(milliseconds: 100), (timer) {
176 if (!clientClosed) { 179 if (!clientClosed) {
177 if (server.connectionsInfo().total == totalConnections) { 180 if (server.connectionsInfo().total == totalConnections) {
178 clientClosed = true; 181 clientClosed = true;
(...skipping 15 matching lines...) Expand all
194 test1(10); 197 test1(10);
195 test2(1, 10); 198 test2(1, 10);
196 test2(10, 10); 199 test2(10, 10);
197 test2(10, 1000); 200 test2(10, 1000);
198 test3(1); 201 test3(1);
199 test3(10); 202 test3(10);
200 test4(); 203 test4();
201 test5(1); 204 test5(1);
202 test5(10); 205 test5(10);
203 } 206 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698