Skip to content

Commit

Permalink
Fixing broken removeContentHeaders function on installs where connect…
Browse files Browse the repository at this point in the history
… is not in path
  • Loading branch information
tomgco committed Jul 21, 2011
1 parent 828ff11 commit 270ac48
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions lib/staticGzip.js
Expand Up @@ -13,15 +13,28 @@ var fs = require('fs'),
path = require('path'),
mime = require('mime'),
compress = require('compress'),
staticSend,
removeContentHeaders;
staticSend;
try {
staticSend = require('connect').static.send;
removeContentHeaders = require('connect').utils.removeContentHeaders;
} catch (e) {
staticSend = require('express').static.send;
removeContentHeaders = require('express').utils.removeContentHeaders;
}

/**
* Strip `Content-*` headers from `res`.
*
* @param {ServerResponse} res
* @api public
*/

var removeContentHeaders = function(res){
Object.keys(res._headers).forEach(function(field){
if (0 === field.indexOf('content')) {
res.removeHeader(field);
}
});
};

/**
* gzipped cache.
*/
Expand Down

0 comments on commit 270ac48

Please sign in to comment.