aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_http_files.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-05-12 03:36:15 +0100
committerMatthew Wild <mwild1@gmail.com>2012-05-12 03:36:15 +0100
commit17c79f8c50c0139bf63a8e01372117efbd233059 (patch)
tree2c8b9cfd14e673bd7bd3af2046abe1edea3cdb61 /plugins/mod_http_files.lua
parentcb80e7171f5ad3248cba3084e914b972a2415f01 (diff)
parent090589dd4b191c1f0a246422e74e8922d8e5cfa4 (diff)
downloadprosody-17c79f8c50c0139bf63a8e01372117efbd233059.tar.gz
prosody-17c79f8c50c0139bf63a8e01372117efbd233059.zip
Merge with Zash
Diffstat (limited to 'plugins/mod_http_files.lua')
-rw-r--r--plugins/mod_http_files.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua
index dc58ff5d..bdc3a011 100644
--- a/plugins/mod_http_files.lua
+++ b/plugins/mod_http_files.lua
@@ -27,11 +27,18 @@ local mime_map = {
function serve_file(event, path)
local response = event.response;
+ local orig_path = event.request.path;
local full_path = http_base.."/"..path;
if stat(full_path, "mode") == "directory" then
- if stat(full_path.."/index.html", "mode") == "file" then
- return serve_file(event, path.."/index.html");
+ if full_path:sub(-1) ~= "/" then
+ response.headers.location = orig_path.."/";
+ return 301;
end
+ if stat(full_path.."index.html", "mode") == "file" then
+ return serve_file(event, path.."index.html");
+ end
+
+ -- TODO File listing
return 403;
end
local f, err = open(full_path, "rb");