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