How to gzip the output in Rikulo Stream?

144 Views Asked by At

I'd like to compress the HTTP response in Rikulo Stream. Do I have to invoke GZIP explicitly? Or, there is an option to enable?

2

There are 2 best solutions below

0
Tom Yeh On BEST ANSWER

You can configure it at startup as follows:

new StreamServer().start()
.then((HttpChannel channel) {
  channel.httpServer.autoCompress = true;
});
0
Günter Zöchbauer On

I haven't tried it and I didn't use Rikulo Stream myself yet but according to server example code I found in the Github Repo it should be possible to set it like

GZIP compression was the default for Dart HTTP server until recently but was changed and needs to be activated explicitely.

void serverInfo(HttpConnect connect) {
  final info = {"name": "Rikulo Stream", "version": connect.server.version};
  server.
      ..autoCompress = true;
      ..defaultResponseHeaders.chunkedTransferEncoding = true;

  connect.response
    ..headers.contentType = getContentType("json")
    ..write(JSON.encode(info));
}