Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix content type for head requests

  • Loading branch information...
commit aa5c70069c28f026a386870ed8df9d9c508f28d9 1 parent a804541
@omphalos authored
Showing with 8 additions and 3 deletions.
  1. +7 −2 crud-file-server.js
  2. +1 −1  package.json
View
9 crud-file-server.js
@@ -66,8 +66,13 @@ exports.handleRequest = function(vpath, path, req, res, readOnly, logHeadRequest
fs.stat(relativePath, function(err, stats) { // determine if the resource is a file or directory
if(err) { writeError(err); }
else {
- res.setHeader('Last-Modified', stats.mtime);
- res.setHeader('Content-Type', stats.isDirectory() ? 'application/json' : 'text/html');
+ res.setHeader('Last-Modified', stats.mtime);
+ if(stats.isDirectory()) {
+ res.setHeader('Content-Type', query.dir == 'json' ? 'application/json' : 'text/html');
+ } else {
+ var type = require('mime').lookup(relativePath);
+ res.setHeader('Content-Type', type);
+ }
res.end();
}
});
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "crud-file-server",
- "version": "0.1.7",
+ "version": "0.1.8",
"description": "file server supporting basic create, read, update, & delete for any kind of file",
"bin": {
"crud-file-server": "./bin/crud-file-server"
Please sign in to comment.
Something went wrong with that request. Please try again.