Skip to content

Commit 784ae53

Browse files
committed
Add req.notModified(), res.setModified().
1 parent 59c203d commit 784ae53

1 file changed

Lines changed: 9 additions & 26 deletions

File tree

index.js

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5777,17 +5777,6 @@ Framework.prototype.responseBinary = function(req, res, contentType, buffer, enc
57775777
return F;
57785778
};
57795779

5780-
/*
5781-
Sets the last modified header or Etag
5782-
@req {Request}
5783-
@res {Response}
5784-
@value {String or Date}
5785-
5786-
if @value === {String} set ETag
5787-
if @value === {Date} set LastModified
5788-
5789-
return {Controller};
5790-
*/
57915780
Framework.prototype.setModified = function(req, res, value) {
57925781
if (typeof(value) === 'string')
57935782
res.setHeader('Etag', value + ':' + F.config['etag-version']);
@@ -5796,21 +5785,6 @@ Framework.prototype.setModified = function(req, res, value) {
57965785
return F;
57975786
};
57985787

5799-
/*
5800-
Checks if ETag or Last Modified has modified
5801-
@req {Request}
5802-
@res {Response}
5803-
@compare {String or Date}
5804-
@strict {Boolean} :: if strict then use equal date else use great than date (default: false)
5805-
5806-
if @compare === {String} compare if-none-match
5807-
if @compare === {Date} compare if-modified-since
5808-
5809-
this method automatically flushes response (if it's not modified)
5810-
--> response 304
5811-
5812-
return {Boolean};
5813-
*/
58145788
Framework.prototype.notModified = function(req, res, compare, strict) {
58155789

58165790
var type = typeof(compare);
@@ -13933,6 +13907,11 @@ http.ServerResponse.prototype.throw400 = function(problem) {
1393313907
F.response400(this.req, this, problem);
1393413908
};
1393513909

13910+
http.ServerResponse.prototype.setModified = function(value) {
13911+
F.setModified(this.req, this, value);
13912+
return this;
13913+
};
13914+
1393613915
http.ServerResponse.prototype.throw401 = function(problem) {
1393713916
this.controller && this.controller.subscribe.success();
1393813917
F.response401(this.req, this, problem);
@@ -14204,6 +14183,10 @@ http.IncomingMessage.prototype.noCache = function() {
1420414183
return self;
1420514184
};
1420614185

14186+
http.IncomingMessage.prototype.notModified = function(compare, strict) {
14187+
return F.notModified(this, this.res, compare, strict);
14188+
};
14189+
1420714190
/**
1420814191
* Read a cookie from current request
1420914192
* @param {String} name Cookie name.

0 commit comments

Comments
 (0)