GZIP on streamToIO
This commit is contained in:
parent
f2822fba00
commit
734d5f8547
3 changed files with 11 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
# angel_static
|
# 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)
|
[![build status](https://travis-ci.org/angel-dart/static.svg?branch=master)](https://travis-ci.org/angel-dart/static)
|
||||||
|
|
||||||
Static server middleware for Angel.
|
Static server middleware for Angel.
|
||||||
|
|
|
@ -122,9 +122,15 @@ class VirtualDirectory implements AngelPlugin {
|
||||||
|
|
||||||
res.headers[HttpHeaders.CONTENT_TYPE] = lookupMimeType(file.path);
|
res.headers[HttpHeaders.CONTENT_TYPE] = lookupMimeType(file.path);
|
||||||
|
|
||||||
if (streamToIO == true)
|
if (streamToIO == true) {
|
||||||
await res.streamFile(file);
|
res
|
||||||
else
|
..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);
|
await res.sendFile(file);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ environment:
|
||||||
sdk: ">=1.19.0"
|
sdk: ">=1.19.0"
|
||||||
homepage: https://github.com/angel-dart/angel_static
|
homepage: https://github.com/angel-dart/angel_static
|
||||||
author: thosakwe <thosakwe@gmail.com>
|
author: thosakwe <thosakwe@gmail.com>
|
||||||
version: 1.1.4
|
version: 1.1.4+1
|
||||||
dependencies:
|
dependencies:
|
||||||
angel_framework: ^1.0.0-dev
|
angel_framework: ^1.0.0-dev
|
||||||
intl: ">=0.0.0 <1.0.0"
|
intl: ">=0.0.0 <1.0.0"
|
||||||
|
|
Loading…
Reference in a new issue