Skip to content

Commit 9dc2314

Browse files
author
Henry Tseng
committed
Added simple mime type content types
Signed-off-by: Henry Tseng <[email protected]>
1 parent 99813af commit 9dc2314

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

lib/routes/statics.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
var fs = require('fs');
44
var url = require('url');
55
var crypto = require('crypto');
6+
var mime = require('mime-types');
67

78
var debug = require('../debug')(process.env.QUIET === 'true');
89

@@ -59,6 +60,9 @@ module.exports = function(options) {
5960
res.setHeader('Last-Modified', new Date(Date.now() + _expirationTime * 1000));
6061
res.setHeader('Cache-Control', "max-age="+ _expirationTime);
6162

63+
// Interpret mime types
64+
res.setHeader('Content-Type', mime.lookup(filePath));
65+
6266
var readStream = fs.createReadStream(filePath);
6367
readStream.on('open', function() {
6468
readStream.pipe(res);

package-lock.json

Lines changed: 22 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hostr",
3-
"version": "2.3.9",
3+
"version": "2.3.10",
44
"description": "A simple web server for the current working directory. Used for hello world style web sites hosting only files in current directory structure. Watches files and integrates with LiveReload.",
55
"repository": {
66
"type": "git",
@@ -28,11 +28,12 @@
2828
"argr": "^1.2.2",
2929
"colors": "^1.1.0",
3030
"lodash": "^4.17.15",
31+
"mime-types": "^2.1.26",
3132
"minimatch": "^3.0.2",
3233
"tiny-lr": "~0.1.4"
3334
},
3435
"devDependencies": {
35-
"yarn": "^1.21.1",
36-
"mocha": "^3.5.3"
36+
"mocha": "^3.5.3",
37+
"yarn": "^1.21.1"
3738
}
3839
}

0 commit comments

Comments
 (0)