Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

configure logging head requests

  • Loading branch information...
commit a804541e1a1536dc7ba03504ecf048f0098cf06d 1 parent b755c6a
@omphalos authored
View
1  README.md
@@ -11,6 +11,7 @@ Command-line usage
This starts a file server using the specified command-line options.
-f file system path to expose over http
+ -h log head requests
-p port to listen on (example, 80)
-q suppress this message
-r read only
View
4 bin/crud-file-server
@@ -12,6 +12,7 @@ if(!argv.q) {
console.log('options:');
console.log('');
console.log(' -f file system path to expose over http');
+ console.log(' -h log head requests');
console.log(' -p port to listen on (example, 80)');
console.log(' -q suppress this message');
console.log(' -r read only');
@@ -27,9 +28,10 @@ var port = argv.p || 80;
var path = argv.f || process.cwd();
var vpath = (argv.v || '').trimLeft();
var readOnly = argv.v;
+var logHeadRequests = argv.h;
require('http').createServer(function (req, res) {
- server.handleRequest(vpath, path, req, res);
+ server.handleRequest(vpath, path, req, res, readOnly, logHeadRequests);
}).listen(port);
console.log('listening on :' + port + '/' + vpath + ', serving ' + path);
View
6 crud-file-server.js
@@ -13,7 +13,7 @@ example usage:
server.handleRequest(port, path, req, res, vpath);
}).listen(port);
*/
-exports.handleRequest = function(vpath, path, req, res, readOnly) {
+exports.handleRequest = function(vpath, path, req, res, readOnly, logHeadRequests) {
// vpath: (optional) virtual path to host in the url
// path: the file system path to serve
// readOnly: whether to allow modifications to the file
@@ -60,7 +60,9 @@ exports.handleRequest = function(vpath, path, req, res, readOnly) {
} else {
switch(req.method) {
case 'HEAD':
- // console.log('head: ' + relativePath);
+ if(logHeadRequests) {
+ console.log('head: ' + relativePath);
+ }
fs.stat(relativePath, function(err, stats) { // determine if the resource is a file or directory
if(err) { writeError(err); }
else {
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "crud-file-server",
- "version": "0.1.6",
+ "version": "0.1.7",
"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.