node-http-server

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 18  →  ?path2? @ 19
/src/handler.js
@@ -53,7 +53,7 @@
const root = path.resolve(requestPath, config.site.index);
fs.stat(root, (error, stats) => {
if (error) {
if(config.site.indexing
if (config.site.indexing
.some((directory) =>
directory.toUpperCase() === requestURL.toUpperCase())) {
fs.readdir(requestPath, (error, paths) => {
@@ -81,12 +81,12 @@
 
return;
}
 
// Could not access directory index file and directory listing not allowed.
response.statusCode = 404;
response.end();
return;
 
}
 
// Serve the document index.
@@ -133,14 +133,13 @@
return;
}
 
switch (stats.isDirectory()) {
case true: // Directory is requested so provide directory indexes.
index(config, request, response, requestPath, requestURL, callback);
break;
default: // Browser requesting file.
files(config, request, response, requestPath, callback);
break;
if (stats.isDirectory()) {
// Directory is requested so provide directory indexes.
index(config, request, response, requestPath, requestURL, callback);
return;
}
// A file was requested so provide the file.
files(config, request, response, requestPath, callback);
});
}
 
@@ -193,33 +192,13 @@
return;
}
 
// Check if the requested path requires authentication.
switch (config.auth.locations.some(
(authPath) => authPath.toUpperCase() === requestURL.pathname.toUpperCase())) {
case true:
// Requested location requires authentication.
authentication.check(request, response, (request, response) => {
process.nextTick(() => {
callback('Authenticated client: ' +
requestAddress.address + ':' +
requestAddress.port +
' accessing: ' +
requestURL.pathname,
module.exports.error.level.INFO
);
});
serve(config,
request,
response,
requestPath,
requestURL.pathname,
callback
);
});
break;
default:
// If authentication is required for this path then perform authentication.
if (config.auth.locations.some(
(authPath) => authPath.toUpperCase() === requestURL.pathname.toUpperCase())) {
// Requested location requires authentication.
authentication.check(request, response, (request, response) => {
process.nextTick(() => {
callback('Client: ' +
callback('Authenticated client: ' +
requestAddress.address + ':' +
requestAddress.port +
' accessing: ' +
@@ -234,8 +213,27 @@
requestURL.pathname,
callback
);
break;
});
return;
}
 
// If no authentication is required then serve the request.
process.nextTick(() => {
callback('Client: ' +
requestAddress.address + ':' +
requestAddress.port +
' accessing: ' +
requestURL.pathname,
module.exports.error.level.INFO
);
});
serve(config,
request,
response,
requestPath,
requestURL.pathname,
callback
);
});
});
}