X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=plugins%2Fmod_httpserver.lua;h=1cdcc78788413fad6f3350d42b5f46b7a2394f58;hb=04cac3474b5d2ef6b40863e683ddb78997d739ee;hp=119ecadce6202fc18e6444fb6c8423f5f00fb956;hpb=0d138c29e945d1e3bd685fda28fad31a17304aee;p=prosody.git diff --git a/plugins/mod_httpserver.lua b/plugins/mod_httpserver.lua index 119ecadc..1cdcc787 100644 --- a/plugins/mod_httpserver.lua +++ b/plugins/mod_httpserver.lua @@ -23,7 +23,7 @@ local mime_map = { 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"; }; @@ -47,16 +47,12 @@ local function preprocess_path(path) 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;