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(); |
+} |