refactor example
This commit is contained in:
parent
17d8f67073
commit
b138f713fa
1 changed files with 6 additions and 10 deletions
|
@ -40,18 +40,14 @@ app.use(function(next){
|
||||||
|
|
||||||
app.use(function(next){
|
app.use(function(next){
|
||||||
return function *(){
|
return function *(){
|
||||||
if (!this.hasContent) return yield next;
|
|
||||||
|
|
||||||
// TODO: fix ...
|
|
||||||
if (!this.body) return yield next;
|
|
||||||
|
|
||||||
if (this.body.readable) {
|
|
||||||
var body = this.body;
|
var body = this.body;
|
||||||
|
|
||||||
|
if (!body || !body.readable) return yield next;
|
||||||
|
|
||||||
var gzip = zlib.createGzip();
|
var gzip = zlib.createGzip();
|
||||||
this.set('Content-Encoding', 'gzip');
|
this.set('Content-Encoding', 'gzip');
|
||||||
this.body = gzip;
|
this.body = gzip;
|
||||||
body.pipe(gzip);
|
body.pipe(gzip);
|
||||||
}
|
|
||||||
|
|
||||||
yield next;
|
yield next;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue