OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 5 |
6 #import("dart:isolate"); | 6 #import("dart:isolate"); |
7 #import("dart:io"); | 7 #import("dart:io"); |
8 | 8 |
9 void setConnectionHeaders(HttpHeaders headers) { | 9 void setConnectionHeaders(HttpHeaders headers) { |
10 headers.add(HttpHeaders.CONNECTION, "my-connection-header1"); | 10 headers.add(HttpHeaders.CONNECTION, "my-connection-header1"); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 conn.onError = (e) => Expect.fail("Unexpected error $e"); | 57 conn.onError = (e) => Expect.fail("Unexpected error $e"); |
58 conn.onRequest = (HttpClientRequest request) { | 58 conn.onRequest = (HttpClientRequest request) { |
59 setConnectionHeaders(request.headers); | 59 setConnectionHeaders(request.headers); |
60 request.persistentConnection = clientPersistentConnection; | 60 request.persistentConnection = clientPersistentConnection; |
61 request.outputStream.close(); | 61 request.outputStream.close(); |
62 }; | 62 }; |
63 conn.onResponse = (HttpClientResponse response) { | 63 conn.onResponse = (HttpClientResponse response) { |
64 Expect.isFalse(response.persistentConnection); | 64 Expect.isFalse(response.persistentConnection); |
65 checkExpectedConnectionHeaders(response.headers, | 65 checkExpectedConnectionHeaders(response.headers, |
66 response.persistentConnection); | 66 response.persistentConnection); |
67 count++; | 67 response.inputStream.onClosed = () { |
68 if (count == totalConnections) { | 68 count++; |
69 client.shutdown(); | 69 if (count == totalConnections) { |
70 server.close(); | 70 client.shutdown(); |
71 } | 71 server.close(); |
| 72 } |
| 73 }; |
72 }; | 74 }; |
73 } | 75 } |
74 } | 76 } |
75 | 77 |
76 | 78 |
77 void main() { | 79 void main() { |
78 test(2, false); | 80 test(2, false); |
79 test(2, true); | 81 test(2, true); |
80 } | 82 } |
OLD | NEW |