Index: tests/standalone/io/http_headers_state_test.dart |
diff --git a/tests/standalone/io/http_headers_state_test.dart b/tests/standalone/io/http_headers_state_test.dart |
index deeb9cd3225cd83b45a4796f2b00d998ae851313..78be5ec9d53ab50032935bb039cbcb8cef77e4c0 100644 |
--- a/tests/standalone/io/http_headers_state_test.dart |
+++ b/tests/standalone/io/http_headers_state_test.dart |
@@ -9,12 +9,11 @@ import "dart:io"; |
void test(int totalConnections, [String body]) { |
HttpServer.bind("127.0.0.1", 0).then((server) { |
- |
server.listen((HttpRequest request) { |
HttpResponse response = request.response; |
// Cannot mutate request headers. |
Expect.throws(() => request.headers.add("X-Request-Header", "value"), |
- (e) => e is HttpException); |
+ (e) => e is HttpException); |
Expect.equals("value", request.headers.value("X-Request-Header")); |
request.listen((_) {}, onDone: () { |
// Can still mutate response headers as long as no data has been sent. |
@@ -22,66 +21,63 @@ void test(int totalConnections, [String body]) { |
if (body != null) { |
response.write(body); |
// Cannot change state or reason when data has been sent. |
- Expect.throws(() => response.statusCode = 200, |
- (e) => e is StateError); |
- Expect.throws(() => response.reasonPhrase = "OK", |
- (e) => e is StateError); |
+ Expect.throws( |
+ () => response.statusCode = 200, (e) => e is StateError); |
+ Expect.throws( |
+ () => response.reasonPhrase = "OK", (e) => e is StateError); |
// Cannot mutate response headers when data has been sent. |
- Expect.throws(() => response.headers.add("X-Request-Header", "value2"), |
- (e) => e is HttpException); |
+ Expect.throws( |
+ () => response.headers.add("X-Request-Header", "value2"), |
+ (e) => e is HttpException); |
} |
response..close(); |
// Cannot change state or reason after connection is closed. |
- Expect.throws(() => response.statusCode = 200, |
- (e) => e is StateError); |
- Expect.throws(() => response.reasonPhrase = "OK", |
- (e) => e is StateError); |
+ Expect.throws(() => response.statusCode = 200, (e) => e is StateError); |
+ Expect.throws( |
+ () => response.reasonPhrase = "OK", (e) => e is StateError); |
// Cannot mutate response headers after connection is closed. |
Expect.throws(() => response.headers.add("X-Request-Header", "value3"), |
- (e) => e is HttpException); |
+ (e) => e is HttpException); |
}); |
}); |
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) { |
- if (body != null) { |
- request.contentLength = -1; |
- } |
- // Can still mutate request headers as long as no data has been sent. |
- request.headers.add("X-Request-Header", "value"); |
- if (body != null) { |
- request.write(body); |
- // Cannot mutate request headers when data has been sent. |
- Expect.throws( |
- () => request.headers.add("X-Request-Header", "value2"), |
- (e) => e is HttpException); |
- } |
- request.close(); |
+ client |
+ .get("127.0.0.1", server.port, "/") |
+ .then((HttpClientRequest request) { |
+ if (body != null) { |
+ request.contentLength = -1; |
+ } |
+ // Can still mutate request headers as long as no data has been sent. |
+ request.headers.add("X-Request-Header", "value"); |
+ if (body != null) { |
+ request.write(body); |
// Cannot mutate request headers when data has been sent. |
- Expect.throws(() => request.headers.add("X-Request-Header", "value3"), |
- (e) => e is HttpException); |
- return request.done; |
- }) |
- .then((HttpClientResponse response) { |
- // Cannot mutate response headers. |
- Expect.throws( |
- () => response.headers.add("X-Response-Header", "value"), |
+ Expect.throws(() => request.headers.add("X-Request-Header", "value2"), |
(e) => e is HttpException); |
- Expect.equals("value", response.headers.value("X-Response-Header")); |
- response.listen((_) {}, onDone: () { |
- // Do not close the connections before we have read the |
- // full response bodies for all connections. |
- if (++count == totalConnections) { |
- client.close(); |
- server.close(); |
- } |
- }); |
+ } |
+ request.close(); |
+ // Cannot mutate request headers when data has been sent. |
+ Expect.throws(() => request.headers.add("X-Request-Header", "value3"), |
+ (e) => e is HttpException); |
+ return request.done; |
+ }).then((HttpClientResponse response) { |
+ // Cannot mutate response headers. |
+ Expect.throws(() => response.headers.add("X-Response-Header", "value"), |
+ (e) => e is HttpException); |
+ Expect.equals("value", response.headers.value("X-Response-Header")); |
+ response.listen((_) {}, onDone: () { |
+ // Do not close the connections before we have read the |
+ // full response bodies for all connections. |
+ if (++count == totalConnections) { |
+ client.close(); |
+ server.close(); |
+ } |
}); |
+ }); |
} |
- |
}); |
} |