refactor example

This commit is contained in:
TJ Holowaychuk 2013-08-27 19:56:35 -07:00
parent 17d8f67073
commit b138f713fa

View file

@ -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; var body = this.body;
// TODO: fix ... if (!body || !body.readable) return yield next;
if (!this.body) return yield next;
if (this.body.readable) { var gzip = zlib.createGzip();
var body = this.body; this.set('Content-Encoding', 'gzip');
var gzip = zlib.createGzip(); this.body = gzip;
this.set('Content-Encoding', 'gzip'); body.pipe(gzip);
this.body = gzip;
body.pipe(gzip);
}
yield next; yield next;
} }