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

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

Issue 14251006: Remove AsyncError with Expando. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 8 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/file_test.dart ('k') | tests/standalone/io/http_content_length_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 // (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // (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";
11 import "dart:isolate"; 11 import "dart:isolate";
12 import "dart:io"; 12 import "dart:io";
13 13
14 // Client makes a HTTP 1.0 request without connection keep alive. The 14 // Client makes a HTTP 1.0 request without connection keep alive. The
15 // server sets a content length but still needs to close the 15 // server sets a content length but still needs to close the
16 // connection as there is no keep alive. 16 // connection as there is no keep alive.
17 void testHttp10NoKeepAlive() { 17 void testHttp10NoKeepAlive() {
18 HttpServer.bind().then((server) { 18 HttpServer.bind().then((server) {
19 server.listen( 19 server.listen(
20 (HttpRequest request) { 20 (HttpRequest request) {
21 Expect.isNull(request.headers.value('content-length')); 21 Expect.isNull(request.headers.value('content-length'));
22 Expect.equals(-1, request.contentLength); 22 Expect.equals(-1, request.contentLength);
23 var response = request.response; 23 var response = request.response;
24 response.contentLength = 1; 24 response.contentLength = 1;
25 Expect.equals("1.0", request.protocolVersion); 25 Expect.equals("1.0", request.protocolVersion);
26 response.done 26 response.done
27 .then((_) => Expect.fail("Unexpected response completion")) 27 .then((_) => Expect.fail("Unexpected response completion"))
28 .catchError((e) => Expect.isTrue(e.error is HttpException)); 28 .catchError((error) => Expect.isTrue(error is HttpException));
29 response.write("Z"); 29 response.write("Z");
30 response.write("Z"); 30 response.write("Z");
31 response.close(); 31 response.close();
32 Expect.throws(() => response.write("x"), 32 Expect.throws(() => response.write("x"),
33 (e) => e is StateError); 33 (e) => e is StateError);
34 }, 34 },
35 onError: (e) => Expect.fail("Unexpected error $e")); 35 onError: (e) {
36 String msg = "Unexpected error $e";
37 var trace = getAttachedStackTrace(e);
38 if (trace != null) msg += "\nStackTrace: $trace";
39 Expect.fail(msg);
40 });
36 41
37 int count = 0; 42 int count = 0;
38 makeRequest() { 43 makeRequest() {
39 Socket.connect("127.0.0.1", server.port).then((socket) { 44 Socket.connect("127.0.0.1", server.port).then((socket) {
40 socket.write("GET / HTTP/1.0\r\n\r\n"); 45 socket.write("GET / HTTP/1.0\r\n\r\n");
41 46
42 List<int> response = []; 47 List<int> response = [];
43 socket.listen( 48 socket.listen(
44 response.addAll, 49 response.addAll,
45 onDone: () { 50 onDone: () {
(...skipping 24 matching lines...) Expand all
70 (HttpRequest request) { 75 (HttpRequest request) {
71 Expect.isNull(request.headers.value('content-length')); 76 Expect.isNull(request.headers.value('content-length'));
72 Expect.equals(-1, request.contentLength); 77 Expect.equals(-1, request.contentLength);
73 request.listen((_) {}, onDone: () { 78 request.listen((_) {}, onDone: () {
74 var response = request.response; 79 var response = request.response;
75 Expect.equals("1.0", request.protocolVersion); 80 Expect.equals("1.0", request.protocolVersion);
76 response.write("Z"); 81 response.write("Z");
77 response.close(); 82 response.close();
78 }); 83 });
79 }, 84 },
80 onError: (e) => Expect.fail("Unexpected error $e")); 85 onError: (e) {
86 String msg = "Unexpected error $e";
87 var trace = getAttachedStackTrace(e);
88 if (trace != null) msg += "\nStackTrace: $trace";
89 Expect.fail(msg);
90 });
81 91
82 int count = 0; 92 int count = 0;
83 makeRequest() { 93 makeRequest() {
84 Socket.connect("127.0.0.1", server.port).then((socket) { 94 Socket.connect("127.0.0.1", server.port).then((socket) {
85 socket.write("GET / HTTP/1.0\r\n"); 95 socket.write("GET / HTTP/1.0\r\n");
86 socket.write("Connection: Keep-Alive\r\n\r\n"); 96 socket.write("Connection: Keep-Alive\r\n\r\n");
87 97
88 List<int> response = []; 98 List<int> response = [];
89 socket.listen( 99 socket.listen(
90 response.addAll, 100 response.addAll,
(...skipping 26 matching lines...) Expand all
117 server.listen( 127 server.listen(
118 (HttpRequest request) { 128 (HttpRequest request) {
119 Expect.isNull(request.headers.value('content-length')); 129 Expect.isNull(request.headers.value('content-length'));
120 Expect.equals(-1, request.contentLength); 130 Expect.equals(-1, request.contentLength);
121 var response = request.response; 131 var response = request.response;
122 response.contentLength = 1; 132 response.contentLength = 1;
123 Expect.equals("1.0", request.protocolVersion); 133 Expect.equals("1.0", request.protocolVersion);
124 response.write("Z"); 134 response.write("Z");
125 response.close(); 135 response.close();
126 }, 136 },
127 onError: (e) => Expect.fail("Unexpected error $e")); 137 onError: (e) {
138 String msg = "Unexpected error $e";
139 var trace = getAttachedStackTrace(e);
140 if (trace != null) msg += "\nStackTrace: $trace";
141 Expect.fail(msg);
142 });
128 143
129 Socket.connect("127.0.0.1", server.port).then((socket) { 144 Socket.connect("127.0.0.1", server.port).then((socket) {
130 void sendRequest() { 145 void sendRequest() {
131 socket.write("GET / HTTP/1.0\r\n"); 146 socket.write("GET / HTTP/1.0\r\n");
132 socket.write("Connection: Keep-Alive\r\n\r\n"); 147 socket.write("Connection: Keep-Alive\r\n\r\n");
133 } 148 }
134 149
135 List<int> response = []; 150 List<int> response = [];
136 int count = 0; 151 int count = 0;
137 socket.listen( 152 socket.listen(
(...skipping 29 matching lines...) Expand all
167 HttpServer.bind().then((server) { 182 HttpServer.bind().then((server) {
168 server.listen( 183 server.listen(
169 (HttpRequest request) { 184 (HttpRequest request) {
170 Expect.isNull(request.headers.value('content-length')); 185 Expect.isNull(request.headers.value('content-length'));
171 Expect.equals(-1, request.contentLength); 186 Expect.equals(-1, request.contentLength);
172 var response = request.response; 187 var response = request.response;
173 Expect.equals("1.0", request.protocolVersion); 188 Expect.equals("1.0", request.protocolVersion);
174 response.write("Z"); 189 response.write("Z");
175 response.close(); 190 response.close();
176 }, 191 },
177 onError: (e) => Expect.fail("Unexpected error $e")); 192 onError: (e) {
193 String msg = "Unexpected error $e";
194 var trace = getAttachedStackTrace(e);
195 if (trace != null) msg += "\nStackTrace: $trace";
196 Expect.fail(msg);
197 });
178 198
179 int count = 0; 199 int count = 0;
180 makeRequest() { 200 makeRequest() {
181 Socket.connect("127.0.0.1", server.port).then((socket) { 201 Socket.connect("127.0.0.1", server.port).then((socket) {
182 socket.write("GET / HTTP/1.0\r\n"); 202 socket.write("GET / HTTP/1.0\r\n");
183 socket.write("Connection: Keep-Alive\r\n\r\n"); 203 socket.write("Connection: Keep-Alive\r\n\r\n");
184 204
185 List<int> response = []; 205 List<int> response = [];
186 socket.listen( 206 socket.listen(
187 response.addAll, 207 response.addAll,
(...skipping 16 matching lines...) Expand all
204 }); 224 });
205 } 225 }
206 226
207 227
208 void main() { 228 void main() {
209 testHttp10NoKeepAlive(); 229 testHttp10NoKeepAlive();
210 testHttp10ServerClose(); 230 testHttp10ServerClose();
211 testHttp10KeepAlive(); 231 testHttp10KeepAlive();
212 testHttp10KeepAliveServerCloses(); 232 testHttp10KeepAliveServerCloses();
213 } 233 }
OLDNEW
« no previous file with comments | « tests/standalone/io/file_test.dart ('k') | tests/standalone/io/http_content_length_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698