[Pkg-javascript-commits] [node-static] 131/151: Fix error with accept-encoding heaer check. Fix bug where Content-Length was sent with a 304 not modified response.

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Tue Jan 7 23:18:03 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 e56d0df6b85edbde97c143f16431967f461b93ef
Author: Dobes Vandermeer <dobesv at gmail.com>
Date:   Sat Nov 12 10:10:59 2011 +0800

    Fix error with accept-encoding heaer check.  Fix bug where Content-Length was sent with a 304 not modified response.
---
 lib/node-static.js | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/lib/node-static.js b/lib/node-static.js
index dbb6d38..9a41b15 100644
--- a/lib/node-static.js
+++ b/lib/node-static.js
@@ -231,7 +231,7 @@ this.Server.prototype.gzipOk = function(req, contentType) {
     if(enable && 
         (typeof enable === 'boolean' || 
             (contentType && (enable instanceof RegExp) && enable.test(contentType)))) {
-        var acceptEncoding && acceptEncoding = req.headers['accept-encoding'];
+        var acceptEncoding = req.headers['accept-encoding'];
         return acceptEncoding && acceptEncoding.indexOf("gzip") >= 0;
     }
     return false;
@@ -253,7 +253,7 @@ this.Server.prototype.respondGzip = function(pathname, status, contentType, _hea
                 stat.size = gzStat.size;
                 files = [gzFile];
             } else {
-                // console.log('gzip file not found or error finding it', gzFile, String(e), stat.isFile());
+                //console.log('gzip file not found or error finding it', gzFile, String(e), stat.isFile());
             }
             that.respondNoGzip(pathname, status, contentType, _headers, files, stat, req, res, finish);
         });
@@ -291,9 +291,26 @@ this.Server.prototype.respondNoGzip = function (pathname, status, contentType, _
     // Conditional GET
     // If the "If-Modified-Since" or "If-None-Match" headers
     // match the conditions, send a 304 Not Modified.
+<<<<<<< HEAD
     if ((clientMTime  || clientETag) &&
         (!clientETag  || clientETag === headers['etag']) &&
         (!clientMTime || clientMTime >= mtime)) {
+=======
+    if (req.headers['if-none-match'] === headers['Etag'] ||
+        Date.parse(req.headers['if-modified-since']) >= mtime) {
+        // 304 response should not contain entity headers
+        ['Content-Encoding',
+         'Content-Language', 
+         'Content-Length', 
+         'Content-Location', 
+         'Content-MD5', 
+         'Content-Range', 
+         'Content-Type', 
+         'Expires',
+         'Last-Modified'].forEach(function(entityHeader) {
+            delete headers[entityHeader];
+        });
+>>>>>>> Fix error with accept-encoding heaer check.  Fix bug where Content-Length was sent with a 304 not modified response.
         finish(304, headers);
     } else {
 <<<<<<< 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