From: Pieter Lexis Date: Fri, 27 Nov 2015 15:56:23 +0000 (+0100) Subject: dnsdist: Add the correct Content-Header for files X-Git-Tag: dnsdist-1.0.0-alpha1~185^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F2950%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Add the correct Content-Header for files --- diff --git a/pdns/dnsdist-web.cc b/pdns/dnsdist-web.cc index e224fe46e4..8eec664b79 100644 --- a/pdns/dnsdist-web.cc +++ b/pdns/dnsdist-web.cc @@ -159,10 +159,19 @@ static void connectionThread(int sock, ComboAddress remote, string password) } else if(!resp.url.path.empty() && g_urlmap.count(resp.url.path.c_str()+1)) { resp.body.assign(g_urlmap[resp.url.path.c_str()+1]); + vector parts; + stringtok(parts, resp.url.path, "."); + if(parts.back() == "html") + resp.headers["Content-Type"] = "text/html"; + else if(parts.back() == "css") + resp.headers["Content-Type"] = "text/css"; + else if(parts.back() == "js") + resp.headers["Content-Type"] = "application/javascript"; resp.status=200; } else if(resp.url.path=="/") { resp.body.assign(g_urlmap["index.html"]); + resp.headers["Content-Type"] = "text/html"; resp.status=200; } else {