Permalink
Browse files

Merging #66

  • Loading branch information...
1 parent 67b723b commit 788203a3ea85b3589c685ee5600c0342a3aa698e @phstc phstc committed Sep 16, 2012
Showing with 21 additions and 7 deletions.
  1. +2 −1 bin/cli.js
  2. +4 −2 lib/node-static.js
  3. +15 −4 test/integration/node-static-test.js
View
3 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);
+
View
6 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] ||
View
19 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);
+}).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);

0 comments on commit 788203a

Please sign in to comment.