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

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

Issue 14640008: Change the signature for all network bind calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments by whesse@ Created 7 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/socket.dart ('k') | tests/standalone/io/http_advanced_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:async"; 11 import "dart:async";
12 import "dart:isolate"; 12 import "dart:isolate";
13 import "dart:io"; 13 import "dart:io";
14 14
15 // Client makes a HTTP 1.0 request without connection keep alive. The 15 // Client makes a HTTP 1.0 request without connection keep alive. The
16 // server sets a content length but still needs to close the 16 // server sets a content length but still needs to close the
17 // connection as there is no keep alive. 17 // connection as there is no keep alive.
18 void testHttp10NoKeepAlive() { 18 void testHttp10NoKeepAlive() {
19 HttpServer.bind().then((server) { 19 HttpServer.bind("127.0.0.1", 0).then((server) {
20 server.listen( 20 server.listen(
21 (HttpRequest request) { 21 (HttpRequest request) {
22 Expect.isNull(request.headers.value('content-length')); 22 Expect.isNull(request.headers.value('content-length'));
23 Expect.equals(-1, request.contentLength); 23 Expect.equals(-1, request.contentLength);
24 var response = request.response; 24 var response = request.response;
25 response.contentLength = 1; 25 response.contentLength = 1;
26 Expect.equals("1.0", request.protocolVersion); 26 Expect.equals("1.0", request.protocolVersion);
27 response.done 27 response.done
28 .then((_) => Expect.fail("Unexpected response completion")) 28 .then((_) => Expect.fail("Unexpected response completion"))
29 .catchError((error) => Expect.isTrue(error is HttpException)); 29 .catchError((error) => Expect.isTrue(error is HttpException));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 makeRequest(); 65 makeRequest();
66 }); 66 });
67 } 67 }
68 68
69 69
70 // Client makes a HTTP 1.0 request and the server does not set a 70 // Client makes a HTTP 1.0 request and the server does not set a
71 // content length so it has to close the connection to mark the end of 71 // content length so it has to close the connection to mark the end of
72 // the response. 72 // the response.
73 void testHttp10ServerClose() { 73 void testHttp10ServerClose() {
74 HttpServer.bind().then((server) { 74 HttpServer.bind("127.0.0.1", 0).then((server) {
75 server.listen( 75 server.listen(
76 (HttpRequest request) { 76 (HttpRequest request) {
77 Expect.isNull(request.headers.value('content-length')); 77 Expect.isNull(request.headers.value('content-length'));
78 Expect.equals(-1, request.contentLength); 78 Expect.equals(-1, request.contentLength);
79 request.listen((_) {}, onDone: () { 79 request.listen((_) {}, onDone: () {
80 var response = request.response; 80 var response = request.response;
81 Expect.equals("1.0", request.protocolVersion); 81 Expect.equals("1.0", request.protocolVersion);
82 response.write("Z"); 82 response.write("Z");
83 response.close(); 83 response.close();
84 }); 84 });
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 117 }
118 makeRequest(); 118 makeRequest();
119 }); 119 });
120 } 120 }
121 121
122 122
123 // Client makes a HTTP 1.0 request with connection keep alive. The 123 // Client makes a HTTP 1.0 request with connection keep alive. The
124 // server sets a content length so the persistent connection can be 124 // server sets a content length so the persistent connection can be
125 // used. 125 // used.
126 void testHttp10KeepAlive() { 126 void testHttp10KeepAlive() {
127 HttpServer.bind().then((server) { 127 HttpServer.bind("127.0.0.1", 0).then((server) {
128 server.listen( 128 server.listen(
129 (HttpRequest request) { 129 (HttpRequest request) {
130 Expect.isNull(request.headers.value('content-length')); 130 Expect.isNull(request.headers.value('content-length'));
131 Expect.equals(-1, request.contentLength); 131 Expect.equals(-1, request.contentLength);
132 var response = request.response; 132 var response = request.response;
133 response.contentLength = 1; 133 response.contentLength = 1;
134 Expect.equals("1.0", request.protocolVersion); 134 Expect.equals("1.0", request.protocolVersion);
135 response.write("Z"); 135 response.write("Z");
136 response.close(); 136 response.close();
137 }, 137 },
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 sendRequest(); 173 sendRequest();
174 }); 174 });
175 }); 175 });
176 } 176 }
177 177
178 178
179 // Client makes a HTTP 1.0 request with connection keep alive. The 179 // Client makes a HTTP 1.0 request with connection keep alive. The
180 // server does not set a content length so it cannot honor connection 180 // server does not set a content length so it cannot honor connection
181 // keep alive. 181 // keep alive.
182 void testHttp10KeepAliveServerCloses() { 182 void testHttp10KeepAliveServerCloses() {
183 HttpServer.bind().then((server) { 183 HttpServer.bind("127.0.0.1", 0).then((server) {
184 server.listen( 184 server.listen(
185 (HttpRequest request) { 185 (HttpRequest request) {
186 Expect.isNull(request.headers.value('content-length')); 186 Expect.isNull(request.headers.value('content-length'));
187 Expect.equals(-1, request.contentLength); 187 Expect.equals(-1, request.contentLength);
188 var response = request.response; 188 var response = request.response;
189 Expect.equals("1.0", request.protocolVersion); 189 Expect.equals("1.0", request.protocolVersion);
190 response.write("Z"); 190 response.write("Z");
191 response.close(); 191 response.close();
192 }, 192 },
193 onError: (e) { 193 onError: (e) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 }); 225 });
226 } 226 }
227 227
228 228
229 void main() { 229 void main() {
230 testHttp10NoKeepAlive(); 230 testHttp10NoKeepAlive();
231 testHttp10ServerClose(); 231 testHttp10ServerClose();
232 testHttp10KeepAlive(); 232 testHttp10KeepAlive();
233 testHttp10KeepAliveServerCloses(); 233 testHttp10KeepAliveServerCloses();
234 } 234 }
OLDNEW
« no previous file with comments | « sdk/lib/io/socket.dart ('k') | tests/standalone/io/http_advanced_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698