[Pkg-javascript-commits] [node-static] 77/151: Merging #66

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Tue Jan 7 23:17:59 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 788203a3ea85b3589c685ee5600c0342a3aa698e
Author: Pablo Cantero <pablo at pablocantero.com>
Date:   Sun Sep 16 13:12:16 2012 -0300

    Merging #66
---
 bin/cli.js                           |  3 ++-
 lib/node-static.js                   |  6 ++++--
 test/integration/node-static-test.js | 19 +++++++++++++++----
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/bin/cli.js b/bin/cli.js
index 659155d..b678643 100755
--- a/bin/cli.js
+++ b/bin/cli.js
@@ -3,7 +3,7 @@
 var fs = require('fs'),
     path = require('path'),
     tty = require('tty'),
-		statik = require('./../lib/node-static');
+    statik = require('./../lib/node-static');
 
     var argv = require('optimist')
         .usage([
@@ -101,3 +101,4 @@ require('http').createServer(function (request, response) {
 }).listen(+argv.port);
 
 console.log('serving "' + dir + '" at http://127.0.0.1:' + argv.port);
+
diff --git a/lib/node-static.js b/lib/node-static.js
index 343baa6..136311b 100644
--- a/lib/node-static.js
+++ b/lib/node-static.js
@@ -31,16 +31,18 @@ this.Server = function (root, options) {
             this.cache = false;
         }
     }
+    
     if ('serverInfo' in this.options) {
         this.serverInfo = this.options.serverInfo.toString();
     } else {
-        this.serverInfo = 'node-static/' + this.version.join('.');
+        this.serverInfo = 'node-static/' + exports.version.join('.');
     }
+    
+    this.defaultHeaders['Server'] = this.serverInfo;
 
     if (this.cache !== false) {
         this.defaultHeaders['Cache-Control'] = 'max-age=' + this.cache;
     }
-    this.defaultHeaders['Server'] = this.serverInfo;
 
     for (var k in this.defaultHeaders) {
         this.options.headers[k] = this.options.headers[k] ||
diff --git a/test/integration/node-static-test.js b/test/integration/node-static-test.js
index 0bcb7d5..5501343 100644
--- a/test/integration/node-static-test.js
+++ b/test/integration/node-static-test.js
@@ -3,7 +3,7 @@ var vows = require('vows')
 	, assert = require('assert')
 	,	static = require('../../lib/node-static');
 
-var fileServer = new(static.Server)(__dirname + '/../fixtures', {});
+var fileServer = new(static.Server)(__dirname + '/../fixtures', {serverInfo: "custom-server-name"});
 
 var suite = vows.describe('node-static');
 
@@ -21,7 +21,9 @@ suite.addBatch({
       }).listen(TEST_PORT, this.callback)
     },
     'should be listening' : function(){
-			assert.isTrue(true);
+      /* This test is necessary to ensure the topic execution.
+       * A topic without tests will be not executed */
+      assert.isTrue(true);
     }
   }
 }).addBatch({
@@ -49,7 +51,7 @@ suite.addBatch({
     }
   }
 }).addBatch({
-  'implicit serving index.html': {
+  'serving directory index': {
     topic : function(){
       request.get(TEST_SERVER, this.callback);
     }, 
@@ -101,4 +103,13 @@ suite.addBatch({
       assert.isUndefined(body);
     }
   }
-}).export(module);
\ No newline at end of file
+}).addBatch({
+  'requesting headers': {
+    topic : function(){
+      request.head(TEST_SERVER + '/index.html', this.callback);
+    },
+    'should respond with node-static/0.6.0' : function(error, response, body){
+      assert.equal(response.headers["server"], "custom-server-name");
+    } 
+  }
+}).export(module);

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