mcavage/node-restify — Issue #68: res.header('Last-Modified', new Date())
Author: fnogatz
Created: 2012-02-03 17:39:49+00:00
State: open

Hi Mark,

I want to set the Last-Modified header as a HTTP-date. You have a httpDate() function in [response.js](https://github.com/mcavage/node-restify/blob/master/lib/response.js#L58-75). It would be nice to simply change headers to dates with

res.header('Last-Modified', new Date());
res.header('Date', new Date());

So the setter should use the httpDate() function instead of the normal toString() when it's a date.

I'm not sure what's the best way. Despite the way of changing the setters there might be also the possibility to use the headers like

server.use(function(req, res, next) {
res.header('Last-Modified', new Date());
});

server.get('/some/route', function(req, res, next) {
var modifiedDate = res.header('Last-Modified'); // return Date-Object instead of String!
console.log(modifiedDate.getMonth());
});

Then you can use the date headers like you have set them: as Date objects. In this case httpDate() should be called only when really writing the Head. Okay: I could simply do a `new Date(res.header('Date'))` :)
My main purpose is to set dates easily as HTTP-dates with `res.header('Date', new Date())`.

Greetings,
Falco