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

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

Issue 11614028: Revert "Fixes to eventhandler and HTTP" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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/socket_stream_impl.dart ('k') | tests/standalone/standalone.status » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 5
6 import "dart:isolate"; 6 import "dart:isolate";
7 import "dart:io"; 7 import "dart:io";
8 8
9 void test1(int totalConnections) { 9 void test1(int totalConnections) {
10 // Server which just closes immediately. 10 // Server which just closes immediately.
(...skipping 16 matching lines...) Expand all
27 if (count == totalConnections) { 27 if (count == totalConnections) {
28 client.shutdown(); 28 client.shutdown();
29 server.close(); 29 server.close();
30 } 30 }
31 }; 31 };
32 }; 32 };
33 } 33 }
34 } 34 }
35 35
36 36
37 void test2(int totalConnections, int outputStreamWrites) { 37 void test2(int totalConnections) {
38 // Server which responds without waiting for request body. 38 // Server which responds without waiting for request body.
39 HttpServer server = new HttpServer(); 39 HttpServer server = new HttpServer();
40 server.listen("127.0.0.1", 0, backlog: totalConnections); 40 server.listen("127.0.0.1", 0, backlog: totalConnections);
41 server.defaultRequestHandler = (HttpRequest request, HttpResponse response) { 41 server.defaultRequestHandler = (HttpRequest request, HttpResponse response) {
42 response.outputStream.writeString("!dlrow ,olleH"); 42 response.outputStream.writeString("!dlrow ,olleH");
43 response.outputStream.close(); 43 response.outputStream.close();
44 }; 44 };
45 45
46 int count = 0; 46 int count = 0;
47 HttpClient client = new HttpClient(); 47 HttpClient client = new HttpClient();
48 for (int i = 0; i < totalConnections; i++) { 48 for (int i = 0; i < totalConnections; i++) {
49 HttpClientConnection conn = client.get("127.0.0.1", server.port, "/"); 49 HttpClientConnection conn = client.get("127.0.0.1", server.port, "/");
50 conn.onRequest = (HttpClientRequest request) { 50 conn.onRequest = (HttpClientRequest request) {
51 request.contentLength = -1; 51 request.contentLength = -1;
52 for (int i = 0; i < outputStreamWrites; i++) 52 request.outputStream.writeString("Hello, world!");
53 request.outputStream.writeString("Hello, world!");
54 request.outputStream.close(); 53 request.outputStream.close();
55 }; 54 };
56 conn.onResponse = (HttpClientResponse response) { 55 conn.onResponse = (HttpClientResponse response) {
57 response.inputStream.onData = response.inputStream.read; 56 response.inputStream.onData = response.inputStream.read;
58 response.inputStream.onClosed = () { 57 response.inputStream.onClosed = () {
59 count++; 58 count++;
60 if (count == totalConnections) { 59 if (count == totalConnections) {
61 client.shutdown(); 60 client.shutdown();
62 server.close(); 61 server.close();
63 } 62 }
64 }; 63 };
65 }; 64 };
66 conn.onError = (e) {
67 count++;
68 if (count == totalConnections) {
69 client.shutdown();
70 server.close();
71 }
72 };
73 } 65 }
74 } 66 }
75 67
76 68
77 void test3(int totalConnections) { 69 void test3(int totalConnections) {
78 // Server which responds when request body has been received. 70 // Server which responds when request body has been received.
79 HttpServer server = new HttpServer(); 71 HttpServer server = new HttpServer();
80 server.listen("127.0.0.1", 0, backlog: totalConnections); 72 server.listen("127.0.0.1", 0, backlog: totalConnections);
81 server.defaultRequestHandler = (HttpRequest request, HttpResponse response) { 73 server.defaultRequestHandler = (HttpRequest request, HttpResponse response) {
82 request.inputStream.onData = () { 74 request.inputStream.onData = () {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 timer.cancel(); 161 timer.cancel();
170 } 162 }
171 } 163 }
172 }); 164 });
173 } 165 }
174 166
175 167
176 void main() { 168 void main() {
177 test1(1); 169 test1(1);
178 test1(10); 170 test1(10);
179 test2(1, 10); 171 test2(1);
180 test2(10, 10); 172 test2(10);
181 test2(10, 1000);
182 test3(1); 173 test3(1);
183 test3(10); 174 test3(10);
184 test4(); 175 test4();
185 test5(1); 176 test5(1);
186 test5(10); 177 test5(10);
187 } 178 }
OLDNEW
« no previous file with comments | « sdk/lib/io/socket_stream_impl.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698