Comparison

plugins/mod_http_files.lua @ 5716:8a0465de172e

mod_http_files: Put the MIME type map in a global shared table instead of per-host
author Kim Alvefur <zash@zash.se>
date Fri, 28 Jun 2013 19:34:57 +0200
parent 5269:7bc52402966d
child 5718:16db80c2b74d
child 6030:9b91242cc137
comparison
equal deleted inserted replaced
5714:520671c3159c 5716:8a0465de172e
17 17
18 local base_path = module:get_option_string("http_files_dir", module:get_option_string("http_path")); 18 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" }); 19 local dir_indices = module:get_option("http_index_files", { "index.html", "index.htm" });
20 local directory_index = module:get_option_boolean("http_dir_listing"); 20 local directory_index = module:get_option_boolean("http_dir_listing");
21 21
22 local mime_map = module:shared("mime").types; 22 local mime_map = module:shared("/*/http_files/mime").types;
23 if not mime_map then 23 if not mime_map then
24 mime_map = { 24 mime_map = {
25 html = "text/html", htm = "text/html", 25 html = "text/html", htm = "text/html",
26 xml = "application/xml", 26 xml = "application/xml",
27 txt = "text/plain", 27 txt = "text/plain",
30 png = "image/png", 30 png = "image/png",
31 gif = "image/gif", 31 gif = "image/gif",
32 jpeg = "image/jpeg", jpg = "image/jpeg", 32 jpeg = "image/jpeg", jpg = "image/jpeg",
33 svg = "image/svg+xml", 33 svg = "image/svg+xml",
34 }; 34 };
35 module:shared("mime").types = mime_map; 35 module:shared("/*/http_files/mime").types = mime_map;
36 36
37 local mime_types, err = open(module:get_option_string("mime_types_file", "/etc/mime.types"),"r"); 37 local mime_types, err = open(module:get_option_string("mime_types_file", "/etc/mime.types"),"r");
38 if mime_types then 38 if mime_types then
39 local mime_data = mime_types:read("*a"); 39 local mime_data = mime_types:read("*a");
40 mime_types:close(); 40 mime_types:close();