From fe20a1c1c5d4e8a2728b25d51e91c817b4330b9c Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Fri, 27 Nov 2015 16:56:23 +0100 Subject: [PATCH] dnsdist: Add the correct Content-Header for files --- pdns/dnsdist-web.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pdns/dnsdist-web.cc b/pdns/dnsdist-web.cc index e224fe46e..8eec664b7 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 { -- 2.49.0