Permalink
Browse files

fixed a compress() bug

  • Loading branch information...
1 parent 1d59745 commit 73544d9fa30235be85800d2535cf544b2fe18eb2 @tj tj committed Dec 7, 2011
Showing with 18 additions and 2 deletions.
  1. +1 −0 lib/middleware/compress.js
  2. +2 −1 package.json
  3. +14 −0 test/compress.js
  4. +1 −1 test/responseTime.js
@@ -82,6 +82,7 @@ module.exports = function compress(options) {
};
res.end = function(chunk, encoding){
+ if (!res.headerSent) this._implicitHeader();
if (chunk) this.write(chunk, encoding);
return stream.end();
};
View
@@ -9,7 +9,8 @@
"dependencies": {
"qs": ">= 0.4.0",
"mime": ">= 0.0.1",
- "formidable": "1.0.x"
+ "formidable": "1.0.x",
+ "debug": "*"
@tojocky

tojocky Dec 14, 2011

Is this module require here?

},
"devDependencies": {
"koala": "0.1.2",
View
@@ -32,6 +32,20 @@ describe('connect.compress()', function(){
.expect('', done);
})
+ it('should support conditional GETs', function(done){
+ app.request()
+ .get('/todo.txt')
+ .set('Accept-Encoding', 'gzip')
+ .end(function(res){
+ var date = res.headers['last-modified'];
+ app.request()
+ .get('/todo.txt')
+ .set('Accept-Encoding', 'gzip')
+ .set('If-Modified-Since', date)
+ .expect(304, done);
+ });
+ })
+
it('should set Vary', function(done){
app.request()
.get('/todo.txt')
View
@@ -8,7 +8,7 @@ app.use(connect.responseTime());
app.use(function(req, res){
setTimeout(function(){
res.end();
- }, 20);
+ }, 30);
});
describe('connect.responseTime()', function(){

0 comments on commit 73544d9

Please sign in to comment.