diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Http.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Http.cc b/src/Http.cc index 4e3e2a6..4ae240e 100644 --- a/src/Http.cc +++ b/src/Http.cc @@ -1,3 +1,5 @@ +#include <map> + #include "Http.h" const char * Balau::Http::getStatusMsg(int httpStatus) { @@ -46,3 +48,19 @@ const char * Balau::Http::getStatusMsg(int httpStatus) { } return "Unknown HTTP code"; } + +static std::map<Balau::String, const char *> s_mimeMap { + std::make_pair("css", "text/css"), + std::make_pair("html", "text/html"), + std::make_pair("js", "application/javascript"), + std::make_pair("json", "application/json"), + std::make_pair("png", "image/png"), + std::make_pair("gif", "image/gif"), +}; + +const char * Balau::Http::getContentType(const String & extension) { + auto t = s_mimeMap.find(extension); + if (t == s_mimeMap.end()) + return "application/octet-stream"; + return t->second; +} |