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

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

Issue 12758009: Support GZip encoding on the http server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add new test Created 7 years, 9 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
« sdk/lib/io/http_impl.dart ('K') | « tests/standalone/io/http_10_test.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_compression_test.dart
diff --git a/tests/standalone/io/http_compression_test.dart b/tests/standalone/io/http_compression_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3b945632611f111d714981bea82a2a94566568e1
--- /dev/null
+++ b/tests/standalone/io/http_compression_test.dart
@@ -0,0 +1,43 @@
+// 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:io';
+
+void testServerCompress() {
+ var data = "My raw server provided data";
Søren Gjesse 2013/03/12 08:54:09 Extend the test with a huge body ad well.
Anders Johnsen 2013/03/12 10:04:59 Done.
+ HttpServer.bind().then((server) {
+ server.listen((request) {
+ request.response.write(data);
+ request.response.close();
+ });
+ var client = new HttpClient();
+ client.get("localhost", server.port, "/")
+ .then((request) {
+ request.headers.set(HttpHeaders.ACCEPT_ENCODING, "gzip");
+ return request.close();
+ })
+ .then((response) {
Søren Gjesse 2013/03/12 08:54:09 Check that Content-Encoding is gzip.
Anders Johnsen 2013/03/12 10:04:59 Done.
+ response
+ .transform(new ZLibInflater())
+ .transform(new StringDecoder())
+ .reduce(new StringBuffer(), (buffer, str) {
+ buffer.write(str);
+ return buffer;
+ }).then((buffer) {
+ Expect.equals(data, buffer.toString());
+ server.close();
+ client.close();
+ });
+ });
+ });
+}
+
+void main() {
+ testServerCompress();
+}
« sdk/lib/io/http_impl.dart ('K') | « tests/standalone/io/http_10_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698