[Pkg-javascript-commits] [node-static] 76/151: allow to set the Server header
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 67b723b94ff69c70c2acb9daa721cf3a86fd090e
Author: Michael Wittig <michael.wittig at tullius-walden.com>
Date: Fri Sep 14 08:04:42 2012 +0200
allow to set the Server header
---
README.md | 9 +++++++++
lib/node-static.js | 11 +++++++----
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index c0d5564..20ca0ec 100644
--- a/README.md
+++ b/README.md
@@ -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.
diff --git a/lib/node-static.js b/lib/node-static.js
index 215e6ad..343baa6 100644
--- a/lib/node-static.js
+++ b/lib/node-static.js
@@ -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('.');
+ }
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) {
--
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