Skip to content

Commit

Permalink
Started staticGzip
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Sep 2, 2010
1 parent e9519cd commit ff2bf35
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/connect/middleware/staticGzip.js
@@ -0,0 +1,14 @@

/*!
* Ext JS Connect
* Copyright(c) 2010 Sencha Inc.
* MIT Licensed
*/

module.exports = function staticGzip(hostname, server){
return function(req, res, next){
var accept = req.headers.accept || '';
// Must Accept: gzip
if (!~accept.indexOf('gzip')) return next();
}
};
35 changes: 35 additions & 0 deletions test/staticGzip.test.js
@@ -0,0 +1,35 @@

/**
* Module dependencies.
*/

var connect = require('connect'),
helpers = require('./helpers'),
assert = require('assert'),
http = require('http');

/**
* Path to ./test/fixtures/
*/

var fixturesPath = __dirname + '/fixtures';

// TODO: Accepts: gzip
// TODO: Transfer-Encoding: gzip

module.exports = {
'test does not Accept gzip': function(){
var server = helpers.run(
connect.staticGzip({ root: fixturesPath, compress: ['text/css'] }),
connect.staticProvider(fixturesPath)
);
var req = server.request('GET', '/style.css');
req.buffer = true;
req.on('response', function(res){
res.on('end', function(){
assert.notEqual('gzip', res.headers['content-encoding']);
});
});
req.end();
}
}

0 comments on commit ff2bf35

Please sign in to comment.