htm = "text/html";
xml = "text/xml";
xsl = "text/xml";
- txt = "plain/text; charset=utf-8";
+ txt = "text/plain; charset=utf-8";
js = "text/javascript";
css = "text/css";
};
end
function serve_file(path)
- local f, err = open(http_base..path, "r");
+ local f, err = open(http_base..path, "rb");
if not f then return response_404; end
local data = f:read("*a");
f:close();
local ext = path:match("%.([^.]*)$");
- local mime = mime_map[ext];
- if not mime then
- mime = ext and "application/octet-stream" or "text/html";
- end
- module:log("warn", "ext: %s, mime: %s", ext, mime);
+ local mime = mime_map[ext]; -- Content-Type should be nil when not known
return {
headers = { ["Content-Type"] = mime; };
body = data;