Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(638)

Unified Diff: tests/standalone/io/http_headers_state_test.dart

Issue 48283002: Throw exception when trying to modify HTTP status code when header is already sent (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 42e5384d825eb6a279c270225648114592e11388..deeb9cd3225cd83b45a4796f2b00d998ae851313 100644
--- a/tests/standalone/io/http_headers_state_test.dart
+++ b/tests/standalone/io/http_headers_state_test.dart
@@ -21,13 +21,23 @@ void test(int totalConnections, [String body]) {
response.headers.add("X-Response-Header", "value");
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);
// Cannot mutate response headers when data has been sent.
- Expect.throws(() => request.headers.add("X-Request-Header", "value2"),
+ Expect.throws(() => response.headers.add("X-Request-Header", "value2"),
(e) => e is HttpException);
}
response..close();
- // Cannot mutate response headers when data has been sent.
- Expect.throws(() => request.headers.add("X-Request-Header", "value3"),
+ // 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);
+ // Cannot mutate response headers after connection is closed.
+ Expect.throws(() => response.headers.add("X-Request-Header", "value3"),
(e) => e is HttpException);
});
});
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698