Skip to content
Myr

Changed: res.send() always checks freshness

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent f25aaf1 · Browse files · 4 files+19 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+19 added−9 removed

  • tests:+16 added−8 removed
  • other:+3 added−1 removed

4 files+19 added−9 removed

modified:lib/response.js+3 added-1 removed
108 unmodified lines
109 if (len > 1024) {110 if (!this.get('ETag')) this.set('ETag', Buffer.isBuffer(body)111 ? crc.buffer.crc32(body)112 : crc.crc32(body));113 if (req.fresh) this.statusCode = 304;113 }114115 // freshness116 if (req.fresh) this.statusCode = 304;117118 // strip irrelevant headers119 if (204 == this.statusCode || 304 == this.statusCode) {120 this.removeHeader('Content-Type');121 this.removeHeader('Content-Length');
528 unmodified lines
modified:test/req.fresh.js+1 added-4 removed
modified:test/req.stale.js+1 added-4 removed
modified:test/res.send.js+14 added
284 unmodified lines
285 })286 })287 })288289 it('should always check freshness', function(done){290 var app = express();291292 app.use(function(req, res, next){293 res.set('ETag', 'asdf');294 res.send('hey');295 });296297 request(app)298 .get('/')299 .set('If-None-Match', 'asdf')300 .expect(304, done);301 })302303 it('should respond with 304 Not Modified when fresh', function(done){304 var app = express();305306 app.use(function(req, res){
10 unmodified lines