Software /
code /
prosody
Comparison
plugins/mod_http_files.lua @ 6031:8796aa94c4b5
Merge 0.9->0.10
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 09 Mar 2014 23:47:53 +0100 |
parent | 5776:bd0ff8ae98a8 |
parent | 6030:9b91242cc137 |
child | 6887:da38775bda82 |
comparison
equal
deleted
inserted
replaced
6027:8c69cea8a1bf | 6031:8796aa94c4b5 |
---|---|
12 | 12 |
13 local os_date = os.date; | 13 local os_date = os.date; |
14 local open = io.open; | 14 local open = io.open; |
15 local stat = lfs.attributes; | 15 local stat = lfs.attributes; |
16 local build_path = require"socket.url".build_path; | 16 local build_path = require"socket.url".build_path; |
17 local path_sep = package.config:sub(1,1); | |
17 | 18 |
18 local base_path = module:get_option_string("http_files_dir", module:get_option_string("http_path")); | 19 local base_path = module:get_option_string("http_files_dir", module:get_option_string("http_path")); |
19 local dir_indices = module:get_option("http_index_files", { "index.html", "index.htm" }); | 20 local dir_indices = module:get_option("http_index_files", { "index.html", "index.htm" }); |
20 local directory_index = module:get_option_boolean("http_dir_listing"); | 21 local directory_index = module:get_option_boolean("http_dir_listing"); |
21 | 22 |
59 local directory_index = opts.directory_index; | 60 local directory_index = opts.directory_index; |
60 local function serve_file(event, path) | 61 local function serve_file(event, path) |
61 local request, response = event.request, event.response; | 62 local request, response = event.request, event.response; |
62 local orig_path = request.path; | 63 local orig_path = request.path; |
63 local full_path = base_path .. (path and "/"..path or ""); | 64 local full_path = base_path .. (path and "/"..path or ""); |
64 local attr = stat(full_path); | 65 local attr = stat((full_path:gsub('%'..path_sep..'+$',''))); |
65 if not attr then | 66 if not attr then |
66 return 404; | 67 return 404; |
67 end | 68 end |
68 | 69 |
69 local request_headers, response_headers = request.headers, response.headers; | 70 local request_headers, response_headers = request.headers, response.headers; |