Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |