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

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

Issue 10449020: Support using the HEAD request in the HTTP library (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 | « runtime/bin/http_parser.dart ('k') | tests/standalone/io/http_parser_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/http_head_test.dart
diff --git a/tests/standalone/io/http_head_test.dart b/tests/standalone/io/http_head_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..56cc54fb51fcd3b448ceda532113b898b1eb8b8c
--- /dev/null
+++ b/tests/standalone/io/http_head_test.dart
@@ -0,0 +1,54 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#import("dart:io");
+
+void testHEAD(int totalConnections) {
+ HttpServer server = new HttpServer();
+ server.onError = (e) => Expect.fail("Unexpected error $e");
+ server.listen("127.0.0.1", 0, totalConnections);
+ server.addRequestHandler(
+ (request) => request.path == "/test100",
+ (HttpRequest request, HttpResponse response) {
+ response.contentLength = 100;
+ response.outputStream.close();
+ });
+ server.addRequestHandler(
+ (request) => request.path == "/test200",
+ (HttpRequest request, HttpResponse response) {
+ response.contentLength = 200;
+ List<int> data = new Uint32List(200);
+ response.outputStream.write(data);
+ response.outputStream.close();
+ });
+
+ HttpClient client = new HttpClient();
+
+ int count = 0;
+ for (int i = 0; i < totalConnections; i++) {
+ HttpClientConnection conn;
+ int len = (i % 2 == 0) ? 100 : 200;
+ if (i % 2 == 0) {
+ conn = client.open("HEAD", "127.0.0.1", server.port, "/test$len");
+ } else {
+ conn = client.open("HEAD", "127.0.0.1", server.port, "/test$len");
+ }
+ conn.onError = (e) => Expect.fail("Unexpected error $e");
+ conn.onResponse = (HttpClientResponse response) {
+ Expect.equals(len, response.contentLength);
+ response.inputStream.onData = () => Expect.fail("Data from HEAD request");
+ response.inputStream.onClosed = () {
+ count++;
+ if (count == totalConnections) {
+ client.shutdown();
+ server.close();
+ }
+ };
+ };
+ }
+}
+
+void main() {
+ testHEAD(4);
+}
« no previous file with comments | « runtime/bin/http_parser.dart ('k') | tests/standalone/io/http_parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698