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

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: Revivew fixes 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
« no previous file with comments | « 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..364be20b8ed550083a21e42c965917d35df92ba7
--- /dev/null
+++ b/tests/standalone/io/http_compression_test.dart
@@ -0,0 +1,52 @@
+// 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';
+import 'dart:scalarlist';
+
+void testServerCompress() {
+ void test(List<int> data) {
+ HttpServer.bind().then((server) {
+ server.listen((request) {
+ request.response.writeBytes(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) {
+ Expect.equals("gzip",
+ response.headers.value(HttpHeaders.CONTENT_ENCODING));
+ response
+ .transform(new ZLibInflater())
+ .reduce([], (list, b) {
+ list.addAll(b);
+ return list;
+ }).then((list) {
+ Expect.listEquals(data, list);
+ server.close();
+ client.close();
+ });
+ });
+ });
+ }
+ test("My raw server provided data".codeUnits);
+ var longBuffer = new Uint8List(1024 * 1024);
+ for (int i = 0; i < longBuffer.length; i++) {
+ longBuffer[i] = i & 0xFF;
+ }
+ test(longBuffer);
+}
+
+void main() {
+ testServerCompress();
+}
« no previous file with comments | « 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