Skip to content

Commit

Permalink
always send ETag when content-length > 0
Browse files Browse the repository at this point in the history
closes #1780
  • Loading branch information
jonathanong committed Oct 31, 2013
1 parent 82a7d7a commit 55d1a4f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/response.js
Expand Up @@ -132,7 +132,7 @@ res.send = function(body){

// ETag support
// TODO: W/ support
if (app.settings.etag && len > 1024 && 'GET' == req.method) {
if (app.settings.etag && len && 'GET' == req.method) {
if (!this.get('ETag')) {
this.set('ETag', etag(body));
}
Expand Down
15 changes: 15 additions & 0 deletions test/res.send.js
Expand Up @@ -321,6 +321,21 @@ describe('res', function(){

describe('"etag" setting', function(){
describe('when enabled', function(){
it('should send ETag even when content-length < 1024', function(done){
var app = express();

app.use(function(req, res){
res.send('kajdslfkasdf');
});

request(app)
.get('/')
.end(function(err, res){
res.headers.should.have.property('etag');
done();
});
})

it('should send ETag ', function(done){
var app = express();

Expand Down

0 comments on commit 55d1a4f

Please sign in to comment.