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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import "dart:async"; | 6 import "dart:async"; |
7 import "dart:io"; | 7 import "dart:io"; |
8 import "dart:isolate"; | 8 import "dart:isolate"; |
9 | 9 |
10 void sendData(List<int> data, int port) { | 10 void sendData(List<int> data, int port) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 makeRequest() { | 118 makeRequest() { |
119 Socket.connect("127.0.0.1", server.port).then((socket) { | 119 Socket.connect("127.0.0.1", server.port).then((socket) { |
120 var data = "GET / HTTP/1.1\r\nContent-Length: 0\r\n\r\n"; | 120 var data = "GET / HTTP/1.1\r\nContent-Length: 0\r\n\r\n"; |
121 socket.write(data); | 121 socket.write(data); |
122 socket.close(); | 122 socket.close(); |
123 socket.done.then((_) { | 123 socket.done.then((_) { |
124 socket.destroy(); | 124 socket.destroy(); |
125 if (++count < 10) { | 125 if (++count < 10) { |
126 makeRequest(); | 126 makeRequest(); |
127 } else { | 127 } else { |
128 server.close(); | 128 runAsync(server.close); |
129 } | 129 } |
130 }); | 130 }); |
131 }); | 131 }); |
132 } | 132 } |
133 makeRequest(); | 133 makeRequest(); |
134 }); | 134 }); |
135 } | 135 } |
136 | 136 |
137 void testEarlyClose3() { | 137 void testEarlyClose3() { |
138 HttpServer.bind("127.0.0.1", 0).then((server) { | 138 HttpServer.bind("127.0.0.1", 0).then((server) { |
(...skipping 18 matching lines...) Expand all Loading... |
157 socket.done.catchError((_) {}); | 157 socket.done.catchError((_) {}); |
158 }); | 158 }); |
159 }); | 159 }); |
160 } | 160 } |
161 | 161 |
162 void main() { | 162 void main() { |
163 testEarlyClose1(); | 163 testEarlyClose1(); |
164 testEarlyClose2(); | 164 testEarlyClose2(); |
165 testEarlyClose3(); | 165 testEarlyClose3(); |
166 } | 166 } |
OLD | NEW |