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

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

Issue 12314065: Reset http-parser instead of only setting _state, when we have handled a full request-response conv… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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_parser.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_keep_alive_test.dart
diff --git a/tests/standalone/io/http_keep_alive_test.dart b/tests/standalone/io/http_keep_alive_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e4783fc3816fafe46c07d70b68ac86f31e0e2a46
--- /dev/null
+++ b/tests/standalone/io/http_keep_alive_test.dart
@@ -0,0 +1,90 @@
+// Copyright (c) 2013, 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.
+//
+// VMOptions=
+// VMOptions=--short_socket_read
+// VMOptions=--short_socket_write
+// VMOptions=--short_socket_read --short_socket_write
+
+import "dart:async";
+import "dart:io";
+
+Future getData(HttpClient client, int port, bool chunked, int length) {
+ return client.get("localhost", port, "/?chunked=$chunked&length=$length")
+ .then((request) => request.close())
+ .then((response) {
+ return response.reduce(0, (bytes, data) => bytes + data.length)
+ .then((bytes) {
+ Expect.equals(length, bytes);
+ });
+ });
+}
+
+Future<HttpServer> startServer() {
+ return HttpServer.bind("127.0.0.1", 0).then((server) {
+ server.listen((request) {
+ bool chunked = request.queryParameters["chunked"] == "true";
+ int length = int.parse(request.queryParameters["length"]);
+ var buffer = new List.fixedLength(length, fill: 0);
+ if (!chunked) request.response.contentLength = length;
+ request.response.add(buffer);
+ request.response.close();
+ });
+ return server;
+ });
+}
+
+testKeepAliveNonChunked() {
+ startServer().then((server) {
+ var client = new HttpClient();
+
+ getData(client, server.port, false, 100)
+ .then((_) => getData(client, server.port, false, 100))
Søren Gjesse 2013/02/22 14:06:41 Maybe add a few more here.
Anders Johnsen 2013/02/22 14:07:48 Done.
+ .then((_) {
+ server.close();
+ client.close();
+ });
+
+ });
+}
+
+testKeepAliveChunked() {
+ startServer().then((server) {
+ var client = new HttpClient();
+
+ getData(client, server.port, true, 100)
+ .then((_) => getData(client, server.port, true, 100))
Søren Gjesse 2013/02/22 14:06:41 and here.
Anders Johnsen 2013/02/22 14:07:48 Done.
+ .then((_) {
+ server.close();
+ client.close();
+ });
+
+ });
+}
+
+testKeepAliveMixed() {
+ startServer().then((server) {
+ var client = new HttpClient();
+
+ getData(client, server.port, true, 100)
+ .then((_) => getData(client, server.port, false, 100))
+ .then((_) => getData(client, server.port, true, 100))
+ .then((_) => getData(client, server.port, false, 100))
+ .then((_) => getData(client, server.port, true, 100))
+ .then((_) => getData(client, server.port, false, 100))
+ .then((_) => getData(client, server.port, true, 100))
+ .then((_) => getData(client, server.port, false, 100))
+ .then((_) {
+ server.close();
+ client.close();
+ });
+
+ });
+}
+
+void main() {
+ testKeepAliveNonChunked();
+ testKeepAliveChunked();
+ testKeepAliveMixed();
+}
« no previous file with comments | « sdk/lib/io/http_parser.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698