Permalink
Browse files

Make tests run on v0.10. Closes #61.

  • Loading branch information...
danmactough committed May 30, 2013
1 parent 8488c4e commit e229eaec4b2b06fdb3344c5590fcabac9e8bc95b
Showing with 26 additions and 13 deletions.
  1. +2 −1 .travis.yml
  2. +2 −3 package.json
  3. +22 −9 test/common.js
View
@@ -1,6 +1,7 @@
language: node_js
node_js:
- - 0.8
+ - "0.8"
+ - "0.10"
branches:
only:
- master
View
@@ -27,14 +27,13 @@
},
"dependencies": {
"sax": "0.5.x",
- "request": "2.9.x",
+ "request": "2.21.x",
"addressparser": "~0.1.3",
"array-indexofobject": "0.0.1",
"resanitize": "~0.1.10"
},
"devDependencies": {
- "mocha": "1.x",
- "buffet": "0.4.x"
+ "mocha": "1.x"
},
"scripts": {
"test": "./node_modules/mocha/bin/mocha"
View
@@ -2,31 +2,44 @@
var URL = require('url');
assert = require('assert');
+var fs = require('fs')
+ , path = require('path')
+ , zlib = require('zlib')
+ , gzip = zlib.createGzip();
+
FeedParser = require('../');
server = function (done) {
var app = require('http').createServer();
- var buffet = require('buffet')({ root: __dirname + '/feeds', indexes: false, watch: false });
app.on('request', function (req, res) {
- var url = URL.parse(req.url, true);
- // gzip the response unless the Accept-Encoding header says otherwise - issue #36
- if (url.query['gzip'] === 'true') {
- req.headers['accept-encoding'] = req.headers['accept-encoding'] || 'deflate, gzip';
- }
+ var url = URL.parse(req.url, true)
+ , file = path.resolve(__dirname, 'feeds', url.pathname.replace(/^\//, ''));
if (url.query['notModified'] === 'true') {
res.writeHead('304', 'Not modified');
res.end();
}
+ else {
+ fs.exists(file, function (exists) {
+ if (!exists) {
+ res.writeHead('404', 'Not found');
+ return res.end();
+ }
+ // gzip the response unless the Accept-Encoding header says otherwise - issue #36
+ if (url.query['gzip'] === 'true' && !req.headers['accept-encoding'].match(/identity/i)) {
+ fs.createReadStream(file).pipe(gzip).pipe(res);
+ }
+ else {
+ fs.createReadStream(file).pipe(res);
+ }
+ });
+ }
});
- app.on('request', buffet);
- app.on('request', buffet.notFound);
app.listen(21337, function () {
done && done();
});
server.app = app;
server.close = function (done) {
app.close.call(app, function (){
delete server.app;
- delete require.cache.buffet;
done && done();
});
};

0 comments on commit e229eae

Please sign in to comment.