mirror of
https://github.com/zebrajr/express.git
synced 2025-12-06 00:19:48 +01:00
Fix exception in req.fresh/req.stale without response headers
fixes #2468
This commit is contained in:
parent
262b60537f
commit
5d74a553d6
|
|
@ -1,3 +1,8 @@
|
|||
3.x
|
||||
===
|
||||
|
||||
* Fix exception in `req.fresh`/`req.stale` without response headers
|
||||
|
||||
3.18.5 / 2014-12-11
|
||||
===================
|
||||
|
||||
|
|
|
|||
|
|
@ -526,7 +526,7 @@ req.__defineGetter__('fresh', function(){
|
|||
|
||||
// 2xx or 304 as per rfc2616 14.26
|
||||
if ((s >= 200 && s < 300) || 304 == s) {
|
||||
return fresh(this.headers, this.res._headers);
|
||||
return fresh(this.headers, (this.res._headers || {}));
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -32,5 +32,18 @@ describe('req', function(){
|
|||
.set('If-None-Match', '"12345"')
|
||||
.expect(200, 'false', done);
|
||||
})
|
||||
|
||||
it('should return false without response headers', function(done){
|
||||
var app = express();
|
||||
|
||||
app.use(function(req, res){
|
||||
res._headers = undefined;
|
||||
res.send(req.fresh);
|
||||
});
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect(200, 'false', done);
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -32,5 +32,18 @@ describe('req', function(){
|
|||
.set('If-None-Match', '"12345"')
|
||||
.expect(200, 'true', done);
|
||||
})
|
||||
|
||||
it('should return true without response headers', function(done){
|
||||
var app = express();
|
||||
|
||||
app.use(function(req, res){
|
||||
res._headers = undefined;
|
||||
res.send(req.stale);
|
||||
});
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect(200, 'true', done);
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user