diff options
Diffstat (limited to 'libcommon/mime.cpp')
-rw-r--r-- | libcommon/mime.cpp | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/libcommon/mime.cpp b/libcommon/mime.cpp deleted file mode 100644 index f64d046..0000000 --- a/libcommon/mime.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "mime.h" - -#include <boost/algorithm/string/predicate.hpp> -#include <boost/beast/http.hpp> - -namespace beast = boost::beast; - -// Return a reasonable mime type based on the extension of a file. -std::string mime_type(const std::string& path) -{ - auto const ext = [&path] - { - auto const pos = path.rfind("."); - if (pos == std::string::npos) - return std::string{}; - return path.substr(pos); - }(); - if(boost::algorithm::istarts_with(ext, ".htm")) return "text/html"; - if(boost::algorithm::istarts_with(ext, ".html")) return "text/html"; - if(boost::algorithm::istarts_with(ext, ".php")) return "text/html"; - if(boost::algorithm::istarts_with(ext, ".css")) return "text/css"; - if(boost::algorithm::istarts_with(ext, ".txt")) return "text/plain"; - if(boost::algorithm::istarts_with(ext, ".js")) return "application/javascript"; - if(boost::algorithm::istarts_with(ext, ".json")) return "application/json"; - if(boost::algorithm::istarts_with(ext, ".xml")) return "application/xml"; - if(boost::algorithm::istarts_with(ext, ".swf")) return "application/x-shockwave-flash"; - if(boost::algorithm::istarts_with(ext, ".flv")) return "video/x-flv"; - if(boost::algorithm::istarts_with(ext, ".png")) return "image/png"; - if(boost::algorithm::istarts_with(ext, ".jpe")) return "image/jpeg"; - if(boost::algorithm::istarts_with(ext, ".jpeg")) return "image/jpeg"; - if(boost::algorithm::istarts_with(ext, ".jpg")) return "image/jpeg"; - if(boost::algorithm::istarts_with(ext, ".gif")) return "image/gif"; - if(boost::algorithm::istarts_with(ext, ".bmp")) return "image/bmp"; - if(boost::algorithm::istarts_with(ext, ".ico")) return "image/vnd.microsoft.icon"; - if(boost::algorithm::istarts_with(ext, ".tiff")) return "image/tiff"; - if(boost::algorithm::istarts_with(ext, ".tif")) return "image/tiff"; - if(boost::algorithm::istarts_with(ext, ".svg")) return "image/svg+xml"; - if(boost::algorithm::istarts_with(ext, ".svgz")) return "image/svg+xml"; - return "application/text"; -} - |