Move MIME type detection to util/HTTP.cpp

This commit is contained in:
EinMByte 2015-09-17 11:59:04 +02:00
parent 17cd149e7f
commit 221e350228
3 changed files with 19 additions and 7 deletions

View file

@ -227,6 +227,19 @@ std::string preprocessContent(const std::string& content, const std::string& pat
return result;
}
std::string getMimeType(const std::string& filename)
{
const std::string ext = filename.substr(filename.find_last_of("."));
if(ext == ".css")
return "text/css";
else if(ext == ".css")
return "text/javascript";
else if(ext == ".html" || ext == ".htm")
return "text/html";
else
return "application/octet-stream";
}
}
}
}

View file

@ -92,6 +92,11 @@ private:
*/
std::string preprocessContent(const std::string& content, const std::string& path);
/**
* @return the MIME type based on the extension of the given filename
*/
std::string getMimeType(const std::string& filename);
}
}
}