#include <MimeTypes.h>
|
static std::string | contentType (const std::string &file) |
|
|
static std::map< std::string, std::string > | mimeType |
|
Definition at line 58 of file MimeTypes.h.
◆ MimeTypes() [1/2]
web::http::MimeTypes::MimeTypes |
( |
const MimeTypes & | | ) |
|
|
delete |
◆ MimeTypes() [2/2]
web::http::MimeTypes::MimeTypes |
( |
| ) |
|
|
private |
Definition at line 244 of file MimeTypes.cpp.
244 {
245#ifdef HAS_LIBMAGIC
246 MimeTypes::magic = magic_open(MAGIC_MIME);
247
248 if (magic_load(magic, nullptr) != 0) {
249 LOG(DEBUG) << "HTTP: Cannot load magic database - " + std::string(magic_error(magic));
250 magic_close(magic);
251 magic = nullptr;
252 }
253#endif
254 }
◆ ~MimeTypes()
web::http::MimeTypes::~MimeTypes |
( |
| ) |
|
|
private |
Definition at line 256 of file MimeTypes.cpp.
256 {
257#ifdef HAS_LIBMAGIC
258 magic_close(MimeTypes::magic);
259#endif
260 }
◆ contentType()
std::string web::http::MimeTypes::contentType |
( |
const std::string & | file | ) |
|
|
static |
Definition at line 262 of file MimeTypes.cpp.
262 {
263 const std::map<std::string, std::string>::iterator it =
mimeType.find(std::filesystem::path(file).extension());
264
265 std::string type;
266
268 type = it->second;
269 }
270#ifdef HAS_LIBMAGIC
271 else if (magic != nullptr) {
272 const char* magicType = magic_file(MimeTypes::magic, file.c_str());
273 type = magicType != nullptr ? magicType : std::string();
274 }
275#endif
276
277 return !type.empty() ? type : "application/octet-stream";
278 }
static std::map< std::string, std::string > mimeType
◆ operator=()
◆ mimeType
std::map< std::string, std::string > web::http::MimeTypes::mimeType |
|
staticprivate |
The documentation for this class was generated from the following files: