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

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

Issue 13861005: Delay HttpClientResponse until HttpClientRequest is fully sent. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove test. 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
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 var client = new HttpClient(); 62 var client = new HttpClient();
63 for (int i = 0; i < connections; i++) { 63 for (int i = 0; i < connections; i++) {
64 client.get("localhost", server.port, "/") 64 client.get("localhost", server.port, "/")
65 .then((request) => request.close()) 65 .then((request) => request.close())
66 .then((response) => check()); 66 .then((response) => check());
67 } 67 }
68 }); 68 });
69 } 69 }
70 70
71 71
72 void testClientCloseDelayed(int connections) {
73 HttpServer.bind().then((server) {
74 int closed = 0;
75 void check() {
76 closed++;
77 // Wait for both server and client to see the connections as closed.
78 if (closed == connections * 2) {
79 Expect.equals(0, server.connectionsInfo().active);
80 Expect.equals(server.connectionsInfo().total,
81 server.connectionsInfo().idle);
82 server.close();
83 }
84 }
85 server.listen((request) {
86 request.pipe(request.response)
87 .then((_) => check());
88 });
89 var client = new HttpClient();
90 for (int i = 0; i < connections; i++) {
91 var req;
92 client.post("localhost", server.port, "/")
93 .then((request) {
94 req = request;
95 request.writeBytes(new Uint8List(1024));
96 return request.response;
97 })
98 .then((response) {
99 req.close();
100 // Ensure we don't accept the response until we have send the entire
101 // request.
102 response.listen(
103 (_) {},
104 onDone: () {
105 check();
106 });
107 });
108 }
109 });
110 }
111
112
113 void testClientCloseSendingResponse(int connections) { 72 void testClientCloseSendingResponse(int connections) {
114 HttpServer.bind().then((server) { 73 HttpServer.bind().then((server) {
115 int closed = 0; 74 int closed = 0;
116 void check() { 75 void check() {
117 closed++; 76 closed++;
118 // Wait for both server and client to see the connections as closed. 77 // Wait for both server and client to see the connections as closed.
119 if (closed == connections * 2) { 78 if (closed == connections * 2) {
120 Expect.equals(0, server.connectionsInfo().active); 79 Expect.equals(0, server.connectionsInfo().active);
121 Expect.equals(server.connectionsInfo().total, 80 Expect.equals(server.connectionsInfo().total,
122 server.connectionsInfo().idle); 81 server.connectionsInfo().idle);
(...skipping 25 matching lines...) Expand all
148 }); 107 });
149 }); 108 });
150 } 109 }
151 }); 110 });
152 } 111 }
153 112
154 113
155 void main() { 114 void main() {
156 testClientAndServerCloseNoListen(10); 115 testClientAndServerCloseNoListen(10);
157 testClientCloseServerListen(10); 116 testClientCloseServerListen(10);
158 testClientCloseDelayed(10);
159 testClientCloseSendingResponse(10); 117 testClientCloseSendingResponse(10);
160 } 118 }
161 119
OLDNEW
« no previous file with comments | « tests/standalone/io/http_client_request_test.dart ('k') | tests/standalone/io/regress_6521_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698