diff options
author | Roland Reichwein <mail@reichwein.it> | 2023-01-03 09:31:51 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2023-01-03 09:31:51 +0100 |
commit | 2b6f8123e925e3be8ce7c04eccdd49fc728314a5 (patch) | |
tree | 78e86bb428b3bc821ae84d0f6abe86136356bd1a /libcommon/mime.cpp | |
parent | 5581340f23b31114d33736c630de849898668f38 (diff) |
Separated out libcommon as libreichwein
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"; -} - |