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

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

Issue 20036002: Don't throw exceptions when adding to a IOSink(StreamSink) after close. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Document the behaviour. Created 7 years, 5 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/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 22 matching lines...) Expand all
33 }); 33 });
34 // write with content length 0 closes the connection and 34 // write with content length 0 closes the connection and
35 // reports an error. 35 // reports an error.
36 response.write("x"); 36 response.write("x");
37 // Subsequent write are ignored as there is already an 37 // Subsequent write are ignored as there is already an
38 // error. 38 // error.
39 response.write("x"); 39 response.write("x");
40 // After an explicit close, write becomes a state error 40 // After an explicit close, write becomes a state error
41 // because we have said we will not add more. 41 // because we have said we will not add more.
42 response.close(); 42 response.close();
43 Expect.throws(() => response.write("x"), 43 response.write("x");
44 (e) => e is StateError);
45 }, 44 },
46 onError: (e) { 45 onError: (e) {
47 String msg = "Unexpected server error $e"; 46 String msg = "Unexpected server error $e";
48 var trace = getAttachedStackTrace(e); 47 var trace = getAttachedStackTrace(e);
49 if (trace != null) msg += "\nStackTrace: $trace"; 48 if (trace != null) msg += "\nStackTrace: $trace";
50 Expect.fail(msg); 49 Expect.fail(msg);
51 }); 50 });
52 51
53 HttpClient client = new HttpClient(); 52 HttpClient client = new HttpClient();
54 for (int i = 0; i < totalConnections; i++) { 53 for (int i = 0; i < totalConnections; i++) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 .then((_) { 98 .then((_) {
100 Expect.fail("Unexpected successful response completion"); 99 Expect.fail("Unexpected successful response completion");
101 }) 100 })
102 .catchError((error) { 101 .catchError((error) {
103 Expect.isTrue(error is HttpException, "[$error]"); 102 Expect.isTrue(error is HttpException, "[$error]");
104 if (++serverCount == totalConnections) { 103 if (++serverCount == totalConnections) {
105 server.close(); 104 server.close();
106 } 105 }
107 }); 106 });
108 response.close(); 107 response.close();
109 Expect.throws(() => response.write("x"), 108 response.write("x");
110 (e) => e is StateError);
111 }); 109 });
112 }, 110 },
113 onError: (e) { 111 onError: (e) {
114 String msg = "Unexpected error $e"; 112 String msg = "Unexpected error $e";
115 var trace = getAttachedStackTrace(e); 113 var trace = getAttachedStackTrace(e);
116 if (trace != null) msg += "\nStackTrace: $trace"; 114 if (trace != null) msg += "\nStackTrace: $trace";
117 Expect.fail(msg); 115 Expect.fail(msg);
118 }); 116 });
119 117
120 int clientCount = 0; 118 int clientCount = 0;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 request.listen( 167 request.listen(
170 (d) {}, 168 (d) {},
171 onDone: () { 169 onDone: () {
172 response.write("x"); 170 response.write("x");
173 Expect.throws( 171 Expect.throws(
174 () => response.headers.chunkedTransferEncoding = false, 172 () => response.headers.chunkedTransferEncoding = false,
175 (e) => e is HttpException); 173 (e) => e is HttpException);
176 response.write("x"); 174 response.write("x");
177 response.write("x"); 175 response.write("x");
178 response.close(); 176 response.close();
179 Expect.throws(() => response.write("x"), 177 response.write("x");
180 (e) => e is StateError);
181 }); 178 });
182 }, 179 },
183 onError: (e) { 180 onError: (e) {
184 String msg = "Unexpected error $e"; 181 String msg = "Unexpected error $e";
185 var trace = getAttachedStackTrace(e); 182 var trace = getAttachedStackTrace(e);
186 if (trace != null) msg += "\nStackTrace: $trace"; 183 if (trace != null) msg += "\nStackTrace: $trace";
187 Expect.fail(msg); 184 Expect.fail(msg);
188 }); 185 });
189 186
190 int count = 0; 187 int count = 0;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 testNoBody(5, false); 257 testNoBody(5, false);
261 testNoBody(25, false); 258 testNoBody(25, false);
262 testNoBody(5, true); 259 testNoBody(5, true);
263 testNoBody(25, true); 260 testNoBody(25, true);
264 testBody(5, false); 261 testBody(5, false);
265 testBody(5, true); 262 testBody(5, true);
266 testBodyChunked(5, false); 263 testBodyChunked(5, false);
267 testBodyChunked(5, true); 264 testBodyChunked(5, true);
268 testSetContentLength(); 265 testSetContentLength();
269 } 266 }
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