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){
|
||||
return function *(){
|
||||
if (!this.hasContent) return yield next;
|
||||
var body = this.body;
|
||||
|
||||
// TODO: fix ...
|
||||
if (!this.body) return yield next;
|
||||
if (!body || !body.readable) return yield next;
|
||||
|
||||
if (this.body.readable) {
|
||||
var body = this.body;
|
||||
var gzip = zlib.createGzip();
|
||||
this.set('Content-Encoding', 'gzip');
|
||||
this.body = gzip;
|
||||
body.pipe(gzip);
|
||||
}
|
||||
var gzip = zlib.createGzip();
|
||||
this.set('Content-Encoding', 'gzip');
|
||||
this.body = gzip;
|
||||
body.pipe(gzip);
|
||||
|
||||
yield next;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue