parent
cd7d241a5d
commit
f87abb3493
@ -2,6 +2,8 @@ unreleased
|
||||
==========
|
||||
|
||||
* Add debug message when loading view engine
|
||||
* Remove usage of `res._headers` private field
|
||||
- Improves compatibility with Node.js 8 nightly
|
||||
* deps: debug@2.6.1
|
||||
- Allow colors in workers
|
||||
- Deprecated `DEBUG_FD` environment variable set to `3` or higher
|
||||
|
@ -452,14 +452,18 @@ defineGetter(req, 'host', deprecate.function(function host(){
|
||||
|
||||
defineGetter(req, 'fresh', function(){
|
||||
var method = this.method;
|
||||
var s = this.res.statusCode;
|
||||
var res = this.res
|
||||
var status = res.statusCode
|
||||
|
||||
// GET or HEAD for weak freshness validation only
|
||||
if ('GET' !== method && 'HEAD' !== method) return false;
|
||||
|
||||
// 2xx or 304 as per rfc2616 14.26
|
||||
if ((s >= 200 && s < 300) || 304 === s) {
|
||||
return fresh(this.headers, (this.res._headers || {}));
|
||||
if ((status >= 200 && status < 300) || 304 === status) {
|
||||
return fresh(this.headers, {
|
||||
'etag': res.get('ETag'),
|
||||
'last-modified': res.get('Last-Modified')
|
||||
})
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -36,8 +36,8 @@ describe('req', function(){
|
||||
it('should return false without response headers', function(done){
|
||||
var app = express();
|
||||
|
||||
app.disable('x-powered-by')
|
||||
app.use(function(req, res){
|
||||
res._headers = null;
|
||||
res.send(req.fresh);
|
||||
});
|
||||
|
||||
|
@ -36,8 +36,8 @@ describe('req', function(){
|
||||
it('should return true without response headers', function(done){
|
||||
var app = express();
|
||||
|
||||
app.disable('x-powered-by')
|
||||
app.use(function(req, res){
|
||||
res._headers = null;
|
||||
res.send(req.stale);
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user