[Pkg-javascript-commits] [node-static] 119/151: Send custom headers even on a 304 Not Modified case

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Tue Jan 7 23:18:02 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository node-static.

commit a364b0cc9433e182a37f764eb003b43a51fc3e9d
Author: Kay <donebizkit at gmail.com>
Date:   Wed May 1 23:09:42 2013 -0700

    Send custom headers even on a 304 Not Modified case
    
    When a 304 (Not Modified) response is sent, user defined headers are not sent. Only default headers are.
    In my case scenario, I need to update the "Set-Cookie" header to extend it every time a user accesses a page. So, even though the page has not changed, therefore generating a 304 response, I still need to send "Set-Cookie" header with a new expiration timestamp.
---
 lib/node-static.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/node-static.js b/lib/node-static.js
index 7784c04..2381590 100644
--- a/lib/node-static.js
+++ b/lib/node-static.js
@@ -203,6 +203,8 @@ Server.prototype.respond = function (pathname, status, _headers, files, stat, re
 
     // Copy default headers
     for (var k in this.options.headers) {  headers[k] = this.options.headers[k] }
+    // Copy custom headers
+    for (var k in _headers) { headers[k] = _headers[k] }
 
     headers['etag']          = JSON.stringify([stat.ino, stat.size, mtime].join('-'));
     headers['date']          = new(Date)().toUTCString();
@@ -220,8 +222,6 @@ Server.prototype.respond = function (pathname, status, _headers, files, stat, re
         headers['content-type']   = mime.lookup(files[0]);
                                    'application/octet-stream';
 
-        for (var k in _headers) { headers[k] = _headers[k] }
-
         res.writeHead(status, headers);
 
         if (req.method === 'HEAD') {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-static.git



More information about the Pkg-javascript-commits mailing list