CLOUD: Move determineMimeType to ResourceHandler

This commit is contained in:
Peter Bozsó 2016-07-28 20:01:33 +02:00 committed by Alexander Tkachev
parent b68bd78b44
commit 64b361b335
4 changed files with 22 additions and 22 deletions

View file

@ -43,7 +43,27 @@ void ResourceHandler::handle(Client &client) {
if (file == nullptr)
return;
LocalWebserver::setClientGetHandler(client, file, 200, LocalWebserver::determineMimeType(filename));
LocalWebserver::setClientGetHandler(client, file, 200, determineMimeType(filename));
}
const char *ResourceHandler::determineMimeType(Common::String &filename) {
// text
if (filename.hasSuffix(".html")) return "text/html";
if (filename.hasSuffix(".css")) return "text/css";
if (filename.hasSuffix(".txt")) return "text/plain";
if (filename.hasSuffix(".js")) return "application/javascript";
// images
if (filename.hasSuffix(".jpeg") || filename.hasSuffix(".jpg") || filename.hasSuffix(".jpe")) return "image/jpeg";
if (filename.hasSuffix(".gif")) return "image/gif";
if (filename.hasSuffix(".png")) return "image/png";
if (filename.hasSuffix(".svg")) return "image/svg+xml";
if (filename.hasSuffix(".tiff")) return "image/tiff";
if (filename.hasSuffix(".ico")) return "image/vnd.microsoft.icon";
if (filename.hasSuffix(".wbmp")) return "image/vnd.wap.wbmp";
if (filename.hasSuffix(".zip")) return "application/zip";
return "application/octet-stream";
}
/// public