diff --git a/README.md b/README.md index 825c811..013bde1 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ For example, you could serve an error page, when the initial request wasn't foun request.addListener('end', function () { fileServer.serve(request, response, function (e, res) { if (e && (e.status === 404)) { // If the file wasn't found - fileServer.serveFile('/not-found.html', request, response); + fileServer.serveFile('/not-found.html', 404, {}, request, response); } }); }); diff --git a/lib/node-static.js b/lib/node-static.js index 9399257..4e90bee 100644 --- a/lib/node-static.js +++ b/lib/node-static.js @@ -17,7 +17,8 @@ var serverInfo = 'node-static/' + this.version.join('.'); this.store = {}; this.indexStore = {}; -this.Server = function (root, options) { +this.Server = function (root, options, indexFile) { + this.indexFile = indexFile; if (root && (typeof(root) === 'object')) { options = root, root = null } this.root = path.resolve(root || '.'); @@ -47,7 +48,7 @@ this.Server = function (root, options) { }; this.Server.prototype.serveDir = function (pathname, req, res, finish) { - var htmlIndex = path.join(pathname, 'index.html'), + var htmlIndex = path.join(pathname, this.indexFile || 'index.html'), that = this; fs.stat(htmlIndex, function (e, stat) { diff --git a/lib/node-static/mime.js b/lib/node-static/mime.js index cdd3355..0b5190b 100644 --- a/lib/node-static/mime.js +++ b/lib/node-static/mime.js @@ -130,6 +130,7 @@ this.contentTypes = { "wrl": "model/vrml", "wvx": "video/x-ms-wvx", "xbm": "image/x-xbitmap", + "xhtml": "application/xhtml+xml", "xlw": "application/vnd.ms-excel", "xml": "text/xml", "xpm": "image/x-xpixmap",