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 "dart:async"; | 10 import "dart:async"; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 server.listen((request) { | 84 server.listen((request) { |
85 request.pipe(request.response) | 85 request.pipe(request.response) |
86 .then((_) => check()); | 86 .then((_) => check()); |
87 }); | 87 }); |
88 var client = new HttpClient(); | 88 var client = new HttpClient(); |
89 for (int i = 0; i < connections; i++) { | 89 for (int i = 0; i < connections; i++) { |
90 var req; | 90 var req; |
91 client.post("localhost", server.port, "/") | 91 client.post("localhost", server.port, "/") |
92 .then((request) { | 92 .then((request) { |
93 req = request; | 93 req = request; |
94 request.add(new Uint8List(1024)); | 94 request.writeBytes(new Uint8List(1024)); |
95 return request.response; | 95 return request.response; |
96 }) | 96 }) |
97 .then((response) { | 97 .then((response) { |
98 req.close(); | 98 req.close(); |
99 // Ensure we don't accept the response until we have send the entire | 99 // Ensure we don't accept the response until we have send the entire |
100 // request. | 100 // request. |
101 response.listen( | 101 response.listen( |
102 (_) {}, | 102 (_) {}, |
103 onDone: () { | 103 onDone: () { |
104 check(); | 104 check(); |
(...skipping 12 matching lines...) Expand all Loading... |
117 // Wait for both server and client to see the connections as closed. | 117 // Wait for both server and client to see the connections as closed. |
118 if (closed == connections * 2) { | 118 if (closed == connections * 2) { |
119 Expect.equals(0, server.connectionsInfo().active); | 119 Expect.equals(0, server.connectionsInfo().active); |
120 Expect.equals(server.connectionsInfo().total, | 120 Expect.equals(server.connectionsInfo().total, |
121 server.connectionsInfo().idle); | 121 server.connectionsInfo().idle); |
122 server.close(); | 122 server.close(); |
123 } | 123 } |
124 } | 124 } |
125 server.listen((request) { | 125 server.listen((request) { |
126 var timer = new Timer.repeating(const Duration(milliseconds: 20), (_) { | 126 var timer = new Timer.repeating(const Duration(milliseconds: 20), (_) { |
127 request.response.add(new Uint8List(16 * 1024)); | 127 request.response.writeBytes(new Uint8List(16 * 1024)); |
128 }); | 128 }); |
129 request.response.done | 129 request.response.done |
130 .catchError((_) {}) | 130 .catchError((_) {}) |
131 .whenComplete(() { | 131 .whenComplete(() { |
132 check(); | 132 check(); |
133 timer.cancel(); | 133 timer.cancel(); |
134 }); | 134 }); |
135 }); | 135 }); |
136 var client = new HttpClient(); | 136 var client = new HttpClient(); |
137 for (int i = 0; i < connections; i++) { | 137 for (int i = 0; i < connections; i++) { |
(...skipping 13 matching lines...) Expand all Loading... |
151 } | 151 } |
152 | 152 |
153 | 153 |
154 void main() { | 154 void main() { |
155 testClientAndServerCloseNoListen(10); | 155 testClientAndServerCloseNoListen(10); |
156 testClientCloseServerListen(10); | 156 testClientCloseServerListen(10); |
157 testClientCloseDelayed(10); | 157 testClientCloseDelayed(10); |
158 testClientCloseSendingResponse(10); | 158 testClientCloseSendingResponse(10); |
159 } | 159 } |
160 | 160 |
OLD | NEW |