OLD | NEW |
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 Loading... |
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 response.write("x"); | 40 Expect.throws(() { |
| 41 response.write("x"); |
| 42 }, (e) => e is StateError); |
41 }, onError: (e, trace) { | 43 }, onError: (e, trace) { |
42 String msg = "Unexpected server error $e"; | 44 String msg = "Unexpected server error $e"; |
43 if (trace != null) msg += "\nStackTrace: $trace"; | 45 if (trace != null) msg += "\nStackTrace: $trace"; |
44 Expect.fail(msg); | 46 Expect.fail(msg); |
45 }); | 47 }); |
46 | 48 |
47 HttpClient client = new HttpClient(); | 49 HttpClient client = new HttpClient(); |
48 for (int i = 0; i < totalConnections; i++) { | 50 for (int i = 0; i < totalConnections; i++) { |
49 client.get("127.0.0.1", server.port, "/").then((request) { | 51 client.get("127.0.0.1", server.port, "/").then((request) { |
50 if (explicitContentLength) { | 52 if (explicitContentLength) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 response.write("x"); | 84 response.write("x"); |
83 response.done.then((_) { | 85 response.done.then((_) { |
84 Expect.fail("Unexpected successful response completion"); | 86 Expect.fail("Unexpected successful response completion"); |
85 }).catchError((error) { | 87 }).catchError((error) { |
86 Expect.isTrue(error is HttpException, "[$error]"); | 88 Expect.isTrue(error is HttpException, "[$error]"); |
87 if (++serverCount == totalConnections) { | 89 if (++serverCount == totalConnections) { |
88 server.close(); | 90 server.close(); |
89 } | 91 } |
90 }); | 92 }); |
91 response.close(); | 93 response.close(); |
92 response.write("x"); | 94 Expect.throws(() { |
| 95 response.write("x"); |
| 96 }, (e) => e is StateError); |
93 }); | 97 }); |
94 }, onError: (e, trace) { | 98 }, onError: (e, trace) { |
95 String msg = "Unexpected error $e"; | 99 String msg = "Unexpected error $e"; |
96 if (trace != null) msg += "\nStackTrace: $trace"; | 100 if (trace != null) msg += "\nStackTrace: $trace"; |
97 Expect.fail(msg); | 101 Expect.fail(msg); |
98 }); | 102 }); |
99 | 103 |
100 int clientCount = 0; | 104 int clientCount = 0; |
101 HttpClient client = new HttpClient(); | 105 HttpClient client = new HttpClient(); |
102 for (int i = 0; i < totalConnections; i++) { | 106 for (int i = 0; i < totalConnections; i++) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 response.headers.set("content-length", 2); | 146 response.headers.set("content-length", 2); |
143 response.headers.set("transfer-encoding", "chunked"); | 147 response.headers.set("transfer-encoding", "chunked"); |
144 } | 148 } |
145 request.listen((d) {}, onDone: () { | 149 request.listen((d) {}, onDone: () { |
146 response.write("x"); | 150 response.write("x"); |
147 Expect.throws(() => response.headers.chunkedTransferEncoding = false, | 151 Expect.throws(() => response.headers.chunkedTransferEncoding = false, |
148 (e) => e is HttpException); | 152 (e) => e is HttpException); |
149 response.write("x"); | 153 response.write("x"); |
150 response.write("x"); | 154 response.write("x"); |
151 response.close(); | 155 response.close(); |
152 response.write("x"); | 156 Expect.throws(() { |
| 157 response.write("x"); |
| 158 }, (e) => e is StateError); |
153 }); | 159 }); |
154 }, onError: (e, trace) { | 160 }, onError: (e, trace) { |
155 String msg = "Unexpected error $e"; | 161 String msg = "Unexpected error $e"; |
156 if (trace != null) msg += "\nStackTrace: $trace"; | 162 if (trace != null) msg += "\nStackTrace: $trace"; |
157 Expect.fail(msg); | 163 Expect.fail(msg); |
158 }); | 164 }); |
159 | 165 |
160 int count = 0; | 166 int count = 0; |
161 HttpClient client = new HttpClient(); | 167 HttpClient client = new HttpClient(); |
162 for (int i = 0; i < totalConnections; i++) { | 168 for (int i = 0; i < totalConnections; i++) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 testNoBody(5, false); | 228 testNoBody(5, false); |
223 testNoBody(25, false); | 229 testNoBody(25, false); |
224 testNoBody(5, true); | 230 testNoBody(5, true); |
225 testNoBody(25, true); | 231 testNoBody(25, true); |
226 testBody(5, false); | 232 testBody(5, false); |
227 testBody(5, true); | 233 testBody(5, true); |
228 testBodyChunked(5, false); | 234 testBodyChunked(5, false); |
229 testBodyChunked(5, true); | 235 testBodyChunked(5, true); |
230 testSetContentLength(); | 236 testSetContentLength(); |
231 } | 237 } |
OLD | NEW |