[Pkg-javascript-commits] [node-static] 136/151: Reverted header check back to original, so we handle one or both of 'If-None-Match' and 'If-Modified-Since' correctly.

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Tue Jan 7 23:18:04 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 00d14759dfb24e85ee44b6067bcda7977d9c278d
Author: thbaja <thbaja at gmail.com>
Date:   Wed Jun 19 16:42:31 2013 +0200

    Reverted header check back to original, so we handle one or both of 'If-None-Match' and 'If-Modified-Since' correctly.
---
 lib/node-static.js | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lib/node-static.js b/lib/node-static.js
index f23faa6..c31c6e3 100644
--- a/lib/node-static.js
+++ b/lib/node-static.js
@@ -233,9 +233,12 @@ Server.prototype.respondGzip = function(pathname, status, contentType, _headers,
 }
 
 Server.prototype.respondNoGzip = function (pathname, status, contentType, _headers, files, stat, req, res, finish) {
-    var mtime   = Date.parse(stat.mtime),
-        key     = pathname || files[0],
-        headers = {};
+    var mtime           = Date.parse(stat.mtime),
+        key             = pathname || files[0],
+        headers         = {},
+        clientETag      = req.headers['if-none-match'],
+        clientMTime     = Date.parse(req.headers['if-modified-since']);
+
 
     // Copy default headers
     for (var k in this.options.headers) {  headers[k] = this.options.headers[k] }
@@ -253,8 +256,9 @@ Server.prototype.respondNoGzip = function (pathname, status, contentType, _heade
     // Conditional GET
     // If the "If-Modified-Since" or "If-None-Match" headers
     // match the conditions, send a 304 Not Modified.
-    if (req.headers['if-none-match'] === headers['Etag'] ||
-        Date.parse(req.headers['if-modified-since']) >= mtime) {
+    if ((clientMTime  || clientETag) &&
+        (!clientETag  || clientETag === headers['Etag']) &&
+        (!clientMTime || clientMTime >= mtime)) {
         // 304 response should not contain entity headers
         ['Content-Encoding',
          'Content-Language', 

-- 
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