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

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

Issue 11642039: Add test of setting HTTP Content-Length through headers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/http_content_length_test.dart
diff --git a/tests/standalone/io/http_content_length_test.dart b/tests/standalone/io/http_content_length_test.dart
index ec22099e163041ead60b38f6e92acc7f015ce114..dfde31f73103b4edfebc23b525d285844af21011 100644
--- a/tests/standalone/io/http_content_length_test.dart
+++ b/tests/standalone/io/http_content_length_test.dart
@@ -47,14 +47,18 @@ void testNoBody(int totalConnections, bool explicitContentLength) {
}
}
-void testBody(int totalConnections) {
+void testBody(int totalConnections, bool useHeader) {
HttpServer server = new HttpServer();
server.onError = (e) => Expect.fail("Unexpected error $e");
server.listen("127.0.0.1", 0, backlog: totalConnections);
server.defaultRequestHandler = (HttpRequest request, HttpResponse response) {
Expect.equals("2", request.headers.value('content-length'));
Expect.equals(2, request.contentLength);
- response.contentLength = 2;
+ if (useHeader) {
+ response.contentLength = 2;
+ } else {
+ response.headers.set("content-length", 2);
+ }
OutputStream stream = response.outputStream;
stream.writeString("x");
Expect.throws(() => response.contentLength = 3, (e) => e is HttpException);
@@ -70,7 +74,12 @@ void testBody(int totalConnections) {
HttpClientConnection conn = client.get("127.0.0.1", server.port, "/");
conn.onError = (e) => Expect.fail("Unexpected error $e");
conn.onRequest = (HttpClientRequest request) {
- request.contentLength = 2;
+ if (useHeader) {
+ request.contentLength = 2;
+ } else {
+ request.headers.add(HttpHeaders.CONTENT_LENGTH, "7");
+ request.headers.add(HttpHeaders.CONTENT_LENGTH, "2");
+ }
OutputStream stream = request.outputStream;
stream.writeString("x");
Expect.throws(() => request.contentLength = 3, (e) => e is HttpException);
@@ -122,6 +131,7 @@ void testHttp10() {
void main() {
testNoBody(5, false);
testNoBody(5, true);
- testBody(5);
+ testBody(5, false);
+ testBody(5, true);
testHttp10();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698