GZIP on streamToIO

This commit is contained in:
thosakwe 2017-04-26 18:39:47 -04:00
parent f2822fba00
commit 734d5f8547
3 changed files with 11 additions and 5 deletions

View file

@ -1,6 +1,6 @@
# angel_static
[![version 1.1.4](https://img.shields.io/badge/pub-1.1.4-brightgreen.svg)](https://pub.dartlang.org/packages/angel_static)
[![version 1.1.4+1](https://img.shields.io/badge/pub-1.1.4+1-brightgreen.svg)](https://pub.dartlang.org/packages/angel_static)
[![build status](https://travis-ci.org/angel-dart/static.svg?branch=master)](https://travis-ci.org/angel-dart/static)
Static server middleware for Angel.

View file

@ -122,9 +122,15 @@ class VirtualDirectory implements AngelPlugin {
res.headers[HttpHeaders.CONTENT_TYPE] = lookupMimeType(file.path);
if (streamToIO == true)
await res.streamFile(file);
else
if (streamToIO == true) {
res
..io.headers.set(HttpHeaders.CONTENT_TYPE, lookupMimeType(file.path))
..io.headers.set(HttpHeaders.CONTENT_ENCODING, 'gzip')
..end()
..willCloseItself = true;
await file.openRead().transform(GZIP.encoder).pipe(res.io);
} else
await res.sendFile(file);
return false;
}

View file

@ -4,7 +4,7 @@ environment:
sdk: ">=1.19.0"
homepage: https://github.com/angel-dart/angel_static
author: thosakwe <thosakwe@gmail.com>
version: 1.1.4
version: 1.1.4+1
dependencies:
angel_framework: ^1.0.0-dev
intl: ">=0.0.0 <1.0.0"