Index: tests/standalone/io/http_connection_header_test.dart |
diff --git a/tests/standalone/io/http_connection_header_test.dart b/tests/standalone/io/http_connection_header_test.dart |
index cd37ead15eb792788330623ae31cbb66d5ef5629..cb2c23d099fececbfde6d858edf00ca6e445ec8a 100644 |
--- a/tests/standalone/io/http_connection_header_test.dart |
+++ b/tests/standalone/io/http_connection_header_test.dart |
@@ -14,20 +14,20 @@ void setConnectionHeaders(HttpHeaders headers) { |
headers.add("My-Connection-Header2", "some-value2"); |
} |
-void checkExpectedConnectionHeaders(HttpHeaders headers, |
- bool persistentConnection) { |
+void checkExpectedConnectionHeaders( |
+ HttpHeaders headers, bool persistentConnection) { |
Expect.equals("some-value1", headers.value("My-Connection-Header1")); |
Expect.equals("some-value2", headers.value("My-Connection-Header2")); |
- Expect.isTrue(headers[HttpHeaders.CONNECTION].any( |
- (value) => value.toLowerCase() == "my-connection-header1")); |
- Expect.isTrue(headers[HttpHeaders.CONNECTION].any( |
- (value) => value.toLowerCase() == "my-connection-header2")); |
+ Expect.isTrue(headers[HttpHeaders.CONNECTION] |
+ .any((value) => value.toLowerCase() == "my-connection-header1")); |
+ Expect.isTrue(headers[HttpHeaders.CONNECTION] |
+ .any((value) => value.toLowerCase() == "my-connection-header2")); |
if (persistentConnection) { |
Expect.equals(2, headers[HttpHeaders.CONNECTION].length); |
} else { |
Expect.equals(3, headers[HttpHeaders.CONNECTION].length); |
- Expect.isTrue(headers[HttpHeaders.CONNECTION].any( |
- (value) => value.toLowerCase() == "close")); |
+ Expect.isTrue(headers[HttpHeaders.CONNECTION] |
+ .any((value) => value.toLowerCase() == "close")); |
} |
} |
@@ -36,10 +36,10 @@ void test(int totalConnections, bool clientPersistentConnection) { |
server.listen((HttpRequest request) { |
// Check expected request. |
Expect.equals(clientPersistentConnection, request.persistentConnection); |
- Expect.equals(clientPersistentConnection, |
- request.response.persistentConnection); |
- checkExpectedConnectionHeaders(request.headers, |
- request.persistentConnection); |
+ Expect.equals( |
+ clientPersistentConnection, request.response.persistentConnection); |
+ checkExpectedConnectionHeaders( |
+ request.headers, request.persistentConnection); |
// Generate response. If the client signaled non-persistent |
// connection the server should not need to set it. |
@@ -53,29 +53,28 @@ void test(int totalConnections, bool clientPersistentConnection) { |
int count = 0; |
HttpClient client = new HttpClient(); |
for (int i = 0; i < totalConnections; i++) { |
- client.get("127.0.0.1", server.port, "/") |
- .then((HttpClientRequest request) { |
- setConnectionHeaders(request.headers); |
- request.persistentConnection = clientPersistentConnection; |
- return request.close(); |
- }) |
- .then((HttpClientResponse response) { |
- Expect.isFalse(response.persistentConnection); |
- checkExpectedConnectionHeaders(response.headers, |
- response.persistentConnection); |
- response.listen((_) {}, onDone: () { |
- count++; |
- if (count == totalConnections) { |
- client.close(); |
- server.close(); |
- } |
- }); |
+ client |
+ .get("127.0.0.1", server.port, "/") |
+ .then((HttpClientRequest request) { |
+ setConnectionHeaders(request.headers); |
+ request.persistentConnection = clientPersistentConnection; |
+ return request.close(); |
+ }).then((HttpClientResponse response) { |
+ Expect.isFalse(response.persistentConnection); |
+ checkExpectedConnectionHeaders( |
+ response.headers, response.persistentConnection); |
+ response.listen((_) {}, onDone: () { |
+ count++; |
+ if (count == totalConnections) { |
+ client.close(); |
+ server.close(); |
+ } |
}); |
+ }); |
} |
}); |
} |
- |
void main() { |
test(2, false); |
test(2, true); |