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

Side by Side Diff: tests/standalone/src/io/HttpShutdownTest.dart

Issue 9653026: Add writeString method to OutputStream (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 8 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 | « tests/standalone/src/io/FileTest.dart ('k') | tests/standalone/src/io/HttpTest.dart » ('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 19 matching lines...) Expand all
30 }; 30 };
31 } 31 }
32 } 32 }
33 33
34 34
35 void test2(int totalConnections) { 35 void test2(int totalConnections) {
36 // Server which responds without waiting for request body. 36 // Server which responds without waiting for request body.
37 HttpServer server = new HttpServer(); 37 HttpServer server = new HttpServer();
38 server.listen("127.0.0.1", 0, totalConnections); 38 server.listen("127.0.0.1", 0, totalConnections);
39 server.onRequest = (HttpRequest request, HttpResponse response) { 39 server.onRequest = (HttpRequest request, HttpResponse response) {
40 response.writeString("!dlrow ,olleH"); 40 response.outputStream.writeString("!dlrow ,olleH");
41 response.outputStream.close(); 41 response.outputStream.close();
42 }; 42 };
43 43
44 int count = 0; 44 int count = 0;
45 HttpClient client = new HttpClient(); 45 HttpClient client = new HttpClient();
46 for (int i = 0; i < totalConnections; i++) { 46 for (int i = 0; i < totalConnections; i++) {
47 HttpClientConnection conn = client.get("127.0.0.1", server.port, "/"); 47 HttpClientConnection conn = client.get("127.0.0.1", server.port, "/");
48 conn.onRequest = (HttpClientRequest request) { 48 conn.onRequest = (HttpClientRequest request) {
49 request.writeString("Hello, world!"); 49 request.outputStream.writeString("Hello, world!");
50 request.outputStream.close(); 50 request.outputStream.close();
51 }; 51 };
52 conn.onResponse = (HttpClientResponse response) { 52 conn.onResponse = (HttpClientResponse response) {
53 count++; 53 count++;
54 if (count == totalConnections) { 54 if (count == totalConnections) {
55 client.shutdown(); 55 client.shutdown();
56 server.close(); 56 server.close();
57 } 57 }
58 }; 58 };
59 } 59 }
60 } 60 }
61 61
62 62
63 void test3(int totalConnections) { 63 void test3(int totalConnections) {
64 // Server which responds when request body has been received. 64 // Server which responds when request body has been received.
65 HttpServer server = new HttpServer(); 65 HttpServer server = new HttpServer();
66 server.listen("127.0.0.1", 0, totalConnections); 66 server.listen("127.0.0.1", 0, totalConnections);
67 server.onRequest = (HttpRequest request, HttpResponse response) { 67 server.onRequest = (HttpRequest request, HttpResponse response) {
68 request.inputStream.onClosed = () { 68 request.inputStream.onClosed = () {
69 response.writeString("!dlrow ,olleH"); 69 response.outputStream.writeString("!dlrow ,olleH");
70 response.outputStream.close(); 70 response.outputStream.close();
71 }; 71 };
72 }; 72 };
73 73
74 int count = 0; 74 int count = 0;
75 HttpClient client = new HttpClient(); 75 HttpClient client = new HttpClient();
76 for (int i = 0; i < totalConnections; i++) { 76 for (int i = 0; i < totalConnections; i++) {
77 HttpClientConnection conn = client.get("127.0.0.1", server.port, "/"); 77 HttpClientConnection conn = client.get("127.0.0.1", server.port, "/");
78 conn.onRequest = (HttpClientRequest request) { 78 conn.onRequest = (HttpClientRequest request) {
79 request.writeString("Hello, world!"); 79 request.outputStream.writeString("Hello, world!");
80 request.outputStream.close(); 80 request.outputStream.close();
81 }; 81 };
82 conn.onResponse = (HttpClientResponse response) { 82 conn.onResponse = (HttpClientResponse response) {
83 count++; 83 count++;
84 if (count == totalConnections) { 84 if (count == totalConnections) {
85 client.shutdown(); 85 client.shutdown();
86 server.close(); 86 server.close();
87 } 87 }
88 }; 88 };
89 } 89 }
90 } 90 }
91 91
92 92
93 void main() { 93 void main() {
94 test1(1); 94 test1(1);
95 test1(10); 95 test1(10);
96 test2(1); 96 test2(1);
97 test2(10); 97 test2(10);
98 test3(1); 98 test3(1);
99 test3(10); 99 test3(10);
100 } 100 }
OLDNEW
« no previous file with comments | « tests/standalone/src/io/FileTest.dart ('k') | tests/standalone/src/io/HttpTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698