Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 // | |
| 5 // VMOptions= | |
| 6 // VMOptions=--short_socket_read | |
| 7 // VMOptions=--short_socket_write | |
| 8 // VMOptions=--short_socket_read --short_socket_write | |
| 9 | |
| 10 import 'dart:io'; | |
| 11 | |
| 12 void testServerCompress() { | |
| 13 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.
| |
| 14 HttpServer.bind().then((server) { | |
| 15 server.listen((request) { | |
| 16 request.response.write(data); | |
| 17 request.response.close(); | |
| 18 }); | |
| 19 var client = new HttpClient(); | |
| 20 client.get("localhost", server.port, "/") | |
| 21 .then((request) { | |
| 22 request.headers.set(HttpHeaders.ACCEPT_ENCODING, "gzip"); | |
| 23 return request.close(); | |
| 24 }) | |
| 25 .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.
| |
| 26 response | |
| 27 .transform(new ZLibInflater()) | |
| 28 .transform(new StringDecoder()) | |
| 29 .reduce(new StringBuffer(), (buffer, str) { | |
| 30 buffer.write(str); | |
| 31 return buffer; | |
| 32 }).then((buffer) { | |
| 33 Expect.equals(data, buffer.toString()); | |
| 34 server.close(); | |
| 35 client.close(); | |
| 36 }); | |
| 37 }); | |
| 38 }); | |
| 39 } | |
| 40 | |
| 41 void main() { | |
| 42 testServerCompress(); | |
| 43 } | |
| OLD | NEW |