]> granicus.if.org Git - pdns/commitdiff
dnsdist: Add the correct Content-Header for files
authorPieter Lexis <pieter.lexis@powerdns.com>
Fri, 27 Nov 2015 15:56:23 +0000 (16:56 +0100)
committerPieter Lexis <pieter.lexis@powerdns.com>
Fri, 27 Nov 2015 15:56:23 +0000 (16:56 +0100)
pdns/dnsdist-web.cc

index e224fe46e4549a09c0f415432f0dce761d3014c5..8eec664b79ab1af8481b1d772778a436420d33dc 100644 (file)
@@ -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<string> 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 {