Software /
code /
prosody
Comparison
plugins/mod_http_files.lua @ 10548:c88f979946c4
mod_http_files: Log something if unable to load MIME database
Not that much to worry about, the most common file types are included in
the code above.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 23 Dec 2019 21:52:50 +0100 |
parent | 9951:f1594893998f |
child | 10778:a62b981db0e2 |
comparison
equal
deleted
inserted
replaced
10547:c77471c180ea | 10548:c88f979946c4 |
---|---|
31 svg = "image/svg+xml", | 31 svg = "image/svg+xml", |
32 }; | 32 }; |
33 module:shared("/*/http_files/mime").types = mime_map; | 33 module:shared("/*/http_files/mime").types = mime_map; |
34 | 34 |
35 local mime_types, err = open(module:get_option_path("mime_types_file", "/etc/mime.types", "config"), "r"); | 35 local mime_types, err = open(module:get_option_path("mime_types_file", "/etc/mime.types", "config"), "r"); |
36 if mime_types then | 36 if not mime_types then |
37 module:log("debug", "Could not open MIME database: %s", err); | |
38 else | |
37 local mime_data = mime_types:read("*a"); | 39 local mime_data = mime_types:read("*a"); |
38 mime_types:close(); | 40 mime_types:close(); |
39 setmetatable(mime_map, { | 41 setmetatable(mime_map, { |
40 __index = function(t, ext) | 42 __index = function(t, ext) |
41 local typ = mime_data:match("\n(%S+)[^\n]*%s"..(ext:lower()).."%s") or "application/octet-stream"; | 43 local typ = mime_data:match("\n(%S+)[^\n]*%s"..(ext:lower()).."%s") or "application/octet-stream"; |