[Pkg-javascript-commits] [node-static] 132/151: Fixed merge issues

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 625151545dbcc8a634a868b33c2322dbd22144d3
Author: thbaja <thbaja at gmail.com>
Date:   Wed Jun 19 15:37:06 2013 +0200

    Fixed merge issues
---
 lib/node-static.js | 82 ------------------------------------------------------
 1 file changed, 82 deletions(-)

diff --git a/lib/node-static.js b/lib/node-static.js
index 9a41b15..51bf3fd 100644
--- a/lib/node-static.js
+++ b/lib/node-static.js
@@ -10,17 +10,8 @@ var fs     = require('fs')
 // Current version
 var version = [0, 6, 9];
 
-<<<<<<< HEAD
-// In-memory file store
-var store      = {};
-var indexStore = {};
-
-Server = function (root, options) {
-    if (root && (typeof(root) === 'object')) { options = root; root = null }
-=======
 this.Server = function (root, options) {
     if (root && (typeof(root) === 'object')) { options = root, root = null }
->>>>>>> Remove in-memory cache
 
     this.root    = path.resolve(root || '.');
     this.options = options || {};
@@ -70,26 +61,12 @@ Server.prototype.serveDir = function (pathname, req, res, finish) {
                 that.respond(null, status, headers, [htmlIndex], stat, req, res, finish);
             }
         } else {
-<<<<<<< HEAD
-            if (pathname in indexStore) {
-                streamFiles(indexStore[pathname].files);
-            } else {
-                // Stream a directory of files as a single file.
-                fs.readFile(path.join(pathname, 'index.json'), function (e, contents) {
-                    if (e) { return finish(404, {}) }
-                    var index = JSON.parse(contents);
-                    indexStore[pathname] = index;
-                    streamFiles(index.files);
-                });
-            }
-=======
             // Stream a directory of files as a single file.
             fs.readFile(path.join(pathname, 'index.json'), function (e, contents) {
                 if (e) { return finish(404, {}) }
                 var index = JSON.parse(contents);
                 streamFiles(index.files);
             });
->>>>>>> Remove in-memory cache
         }
     });
     function streamFiles(files) {
@@ -215,14 +192,6 @@ Server.prototype.serve = function (req, res, callback) {
     if (! callback) { return promise }
 };
 
-<<<<<<< HEAD
-Server.prototype.respond = function (pathname, status, _headers, files, stat, req, res, finish) {
-    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']);
-=======
 /* Check if we should consider sending a gzip version of the file based on the
  * file content type and client's Accept-Encoding header value.
  */
@@ -267,18 +236,12 @@ this.Server.prototype.respondNoGzip = function (pathname, status, contentType, _
     var mtime   = Date.parse(stat.mtime),
         key     = pathname || files[0],
         headers = {};
->>>>>>> Add static gzip file support, where a gzip file with a matching name but adding .gz to the end can be served up to clients that support it.  As part of that, changed the code so the Content-Type and Content-Length are sent even for an HTTP HEAD request.
 
     // 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] }
 
-<<<<<<< HEAD
-    headers['etag']          = JSON.stringify([stat.ino, stat.size, mtime].join('-'));
-    headers['date']          = new(Date)().toUTCString();
-    headers['last-modified'] = new(Date)(stat.mtime).toUTCString();
-=======
     headers['Etag']          = JSON.stringify([stat.ino, stat.size, mtime].join('-'));
     headers['Date']          = new(Date)().toUTCString();
     headers['Last-Modified'] = new(Date)(stat.mtime).toUTCString();
@@ -286,16 +249,10 @@ this.Server.prototype.respondNoGzip = function (pathname, status, contentType, _
     headers['Content-Length'] = stat.size;
     
     for (var k in _headers) { headers[k] = _headers[k] }
->>>>>>> Add static gzip file support, where a gzip file with a matching name but adding .gz to the end can be served up to clients that support it.  As part of that, changed the code so the Content-Type and Content-Length are sent even for an HTTP HEAD request.
 
     // 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
@@ -310,55 +267,17 @@ this.Server.prototype.respondNoGzip = function (pathname, status, contentType, _
          '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
-<<<<<<< HEAD
-        headers['content-length'] = stat.size;
-        headers['content-type']   = mime.lookup(files[0]);
-                                   'application/octet-stream';
-=======
->>>>>>> Add static gzip file support, where a gzip file with a matching name but adding .gz to the end can be served up to clients that support it.  As part of that, changed the code so the Content-Type and Content-Length are sent even for an HTTP HEAD request.
-
-        res.writeHead(status, headers);
-
-        if (req.method === 'HEAD') {
-            finish(200, headers);
-            return;
-        }
-
-        // If the file was cached and it's not older
-        // than what's on disk, serve the cached version.
-        if (this.cache && (key in store) &&
-            store[key].stat.mtime >= stat.mtime) {
-            res.end(store[key].buffer);
-            finish(status, headers);
-        } else {
-            this.stream(pathname, files, new(buffer.Buffer)(stat.size), res, function (e, buffer) {
-                if (e) { return finish(500, {}) }
-                store[key] = {
-                    stat:      stat,
-                    buffer:    buffer,
-                    timestamp: Date.now()
-                };
-                finish(status, headers);
-            });
-        }
-=======
         res.writeHead(status, headers);
 
         this.stream(pathname, files, new(buffer.Buffer)(stat.size), res, function (e, buffer) {
             if (e) { return finish(500, {}) }
             finish(status, headers);
         });
->>>>>>> Remove in-memory cache
     }
 };
 
-<<<<<<< HEAD
-Server.prototype.stream = function (pathname, files, buffer, res, callback) {
-=======
 this.Server.prototype.respond = function (pathname, status, _headers, files, stat, req, res, finish) {
     var contentType = _headers['Content-Type'] || 
                       mime.contentTypes[path.extname(files[0]).slice(1)] ||
@@ -371,7 +290,6 @@ this.Server.prototype.respond = function (pathname, status, _headers, files, sta
 }
 
 this.Server.prototype.stream = function (pathname, files, buffer, res, callback) {
->>>>>>> Add static gzip file support, where a gzip file with a matching name but adding .gz to the end can be served up to clients that support it.  As part of that, changed the code so the Content-Type and Content-Length are sent even for an HTTP HEAD request.
     (function streamFile(files, offset) {
         var file = files.shift();
 

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