serverInfo option added #66

Merged
merged 1 commit into from Sep 16, 2012
Jump to file or symbol
Failed to load files and symbols.
+16 −4
Diff settings

Always

Just for now

View
@@ -131,6 +131,15 @@ Passing `false` will disable the `Cache-Control` header.
> Defaults to `3600`
+
+#### `serverInfo` #
+
+Sets the `Server` header.
+
+example: `{ serverInfo: "myserver" }`
+
+> Defaults to `node-static/{version}`
+
#### `headers` #
Sets response headers.
View
@@ -10,8 +10,6 @@ this.version = [0, 6, 0];
var mime = require('./node-static/mime');
var util = require('./node-static/util');
-var serverInfo = 'node-static/' + this.version.join('.');
-
// In-memory file store
this.store = {};
this.indexStore = {};
@@ -33,11 +31,16 @@ 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 comment has been minimized.

@phstc

phstc Sep 16, 2012

Collaborator

version does not belong to this anymore. you should use this.serverInfo = 'node-static/' + exports.version.join('.'); instead.

@phstc

phstc Sep 16, 2012

Collaborator

version does not belong to this anymore. you should use this.serverInfo = 'node-static/' + exports.version.join('.'); instead.

+ }
if (this.cache !== false) {
this.defaultHeaders['Cache-Control'] = 'max-age=' + this.cache;
}
- this.defaultHeaders['Server'] = serverInfo;
+ this.defaultHeaders['Server'] = this.serverInfo;
for (var k in this.defaultHeaders) {
this.options.headers[k] = this.options.headers[k] ||
@@ -95,7 +98,7 @@ this.Server.prototype.finish = function (status, headers, req, res, promise, cal
message: http.STATUS_CODES[status]
};
- headers['Server'] = serverInfo;
+ headers['Server'] = this.serverInfo;
if (!status || status >= 400) {
if (callback) {