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

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

Issue 2864443002: Revert "Throw when adding something to a closed sink and improve documentation." (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « tests/standalone/io/http_10_test.dart ('k') | tests/standalone/io/socket_exception_test.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) 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 "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
(...skipping 19 matching lines...) Expand all
30 }); 30 });
31 // write with content length 0 closes the connection and 31 // write with content length 0 closes the connection and
32 // reports an error. 32 // reports an error.
33 response.write("x"); 33 response.write("x");
34 // Subsequent write are ignored as there is already an 34 // Subsequent write are ignored as there is already an
35 // error. 35 // error.
36 response.write("x"); 36 response.write("x");
37 // After an explicit close, write becomes a state error 37 // After an explicit close, write becomes a state error
38 // because we have said we will not add more. 38 // because we have said we will not add more.
39 response.close(); 39 response.close();
40 Expect.throws(() { 40 response.write("x");
41 response.write("x");
42 }, (e) => e is StateError);
43 }, onError: (e, trace) { 41 }, onError: (e, trace) {
44 String msg = "Unexpected server error $e"; 42 String msg = "Unexpected server error $e";
45 if (trace != null) msg += "\nStackTrace: $trace"; 43 if (trace != null) msg += "\nStackTrace: $trace";
46 Expect.fail(msg); 44 Expect.fail(msg);
47 }); 45 });
48 46
49 HttpClient client = new HttpClient(); 47 HttpClient client = new HttpClient();
50 for (int i = 0; i < totalConnections; i++) { 48 for (int i = 0; i < totalConnections; i++) {
51 client.get("127.0.0.1", server.port, "/").then((request) { 49 client.get("127.0.0.1", server.port, "/").then((request) {
52 if (explicitContentLength) { 50 if (explicitContentLength) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 response.write("x"); 82 response.write("x");
85 response.done.then((_) { 83 response.done.then((_) {
86 Expect.fail("Unexpected successful response completion"); 84 Expect.fail("Unexpected successful response completion");
87 }).catchError((error) { 85 }).catchError((error) {
88 Expect.isTrue(error is HttpException, "[$error]"); 86 Expect.isTrue(error is HttpException, "[$error]");
89 if (++serverCount == totalConnections) { 87 if (++serverCount == totalConnections) {
90 server.close(); 88 server.close();
91 } 89 }
92 }); 90 });
93 response.close(); 91 response.close();
94 Expect.throws(() { 92 response.write("x");
95 response.write("x");
96 }, (e) => e is StateError);
97 }); 93 });
98 }, onError: (e, trace) { 94 }, onError: (e, trace) {
99 String msg = "Unexpected error $e"; 95 String msg = "Unexpected error $e";
100 if (trace != null) msg += "\nStackTrace: $trace"; 96 if (trace != null) msg += "\nStackTrace: $trace";
101 Expect.fail(msg); 97 Expect.fail(msg);
102 }); 98 });
103 99
104 int clientCount = 0; 100 int clientCount = 0;
105 HttpClient client = new HttpClient(); 101 HttpClient client = new HttpClient();
106 for (int i = 0; i < totalConnections; i++) { 102 for (int i = 0; i < totalConnections; i++) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 response.headers.set("content-length", 2); 142 response.headers.set("content-length", 2);
147 response.headers.set("transfer-encoding", "chunked"); 143 response.headers.set("transfer-encoding", "chunked");
148 } 144 }
149 request.listen((d) {}, onDone: () { 145 request.listen((d) {}, onDone: () {
150 response.write("x"); 146 response.write("x");
151 Expect.throws(() => response.headers.chunkedTransferEncoding = false, 147 Expect.throws(() => response.headers.chunkedTransferEncoding = false,
152 (e) => e is HttpException); 148 (e) => e is HttpException);
153 response.write("x"); 149 response.write("x");
154 response.write("x"); 150 response.write("x");
155 response.close(); 151 response.close();
156 Expect.throws(() { 152 response.write("x");
157 response.write("x");
158 }, (e) => e is StateError);
159 }); 153 });
160 }, onError: (e, trace) { 154 }, onError: (e, trace) {
161 String msg = "Unexpected error $e"; 155 String msg = "Unexpected error $e";
162 if (trace != null) msg += "\nStackTrace: $trace"; 156 if (trace != null) msg += "\nStackTrace: $trace";
163 Expect.fail(msg); 157 Expect.fail(msg);
164 }); 158 });
165 159
166 int count = 0; 160 int count = 0;
167 HttpClient client = new HttpClient(); 161 HttpClient client = new HttpClient();
168 for (int i = 0; i < totalConnections; i++) { 162 for (int i = 0; i < totalConnections; i++) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 testNoBody(5, false); 222 testNoBody(5, false);
229 testNoBody(25, false); 223 testNoBody(25, false);
230 testNoBody(5, true); 224 testNoBody(5, true);
231 testNoBody(25, true); 225 testNoBody(25, true);
232 testBody(5, false); 226 testBody(5, false);
233 testBody(5, true); 227 testBody(5, true);
234 testBodyChunked(5, false); 228 testBodyChunked(5, false);
235 testBodyChunked(5, true); 229 testBodyChunked(5, true);
236 testSetContentLength(); 230 testSetContentLength();
237 } 231 }
OLDNEW
« no previous file with comments | « tests/standalone/io/http_10_test.dart ('k') | tests/standalone/io/socket_exception_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698