node-http-server

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 19  →  ?path2? @ 20
/src/handler.js
@@ -138,8 +138,18 @@
index(config, request, response, requestPath, requestURL, callback);
return;
}
// A file was requested so provide the file.
files(config, request, response, requestPath, callback);
if (stats.isFile()) {
const file = path.parse(requestPath).base;
if (config.site.refuse.some((expression) => expression.test(file)) ||
!config.site.accept.some((expression) => expression.test(file))) {
response.statusCode = 404;
response.end();
return;
}
 
// A file was requested so provide the file.
files(config, request, response, requestPath, callback);
}
});
}
 
@@ -153,15 +163,6 @@
},
process: (config, request, response, root, callback) => {
process.nextTick(() => {
// Create digest authentication.
const authentication = auth.digest({
realm: config.auth.realm,
file: path.resolve(
path.dirname(require.main.filename),
config.auth.digest
)
});
 
const requestAddress = request.socket.address();
const requestURL = url.parse(
request.url, true
@@ -195,6 +196,14 @@
// If authentication is required for this path then perform authentication.
if (config.auth.locations.some(
(authPath) => authPath.toUpperCase() === requestURL.pathname.toUpperCase())) {
// Create digest authentication.
const authentication = auth.digest({
realm: config.auth.realm,
file: path.resolve(
path.dirname(require.main.filename),
config.auth.digest
)
});
// Requested location requires authentication.
authentication.check(request, response, (request, response) => {
process.nextTick(() => {