#include <MimeTypes.h>
|
static std::string | contentType (const std::string &file) |
|
|
static std::map< std::string, std::string > | mimeType |
|
Definition at line 36 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 222 of file MimeTypes.cpp.
222 {
223#ifdef HAS_LIBMAGIC
224 MimeTypes::magic = magic_open(MAGIC_MIME);
225
226 if (magic_load(magic, nullptr) != 0) {
227 LOG(DEBUG) << "HTTP: Cannot load magic database - " + std::string(magic_error(magic));
228 magic_close(magic);
229 magic = nullptr;
230 }
231#endif
232 }
◆ ~MimeTypes()
web::http::MimeTypes::~MimeTypes |
( |
| ) |
|
|
private |
Definition at line 234 of file MimeTypes.cpp.
234 {
235#ifdef HAS_LIBMAGIC
236 magic_close(MimeTypes::magic);
237#endif
238 }
◆ contentType()
std::string web::http::MimeTypes::contentType |
( |
const std::string & | file | ) |
|
|
static |
Definition at line 240 of file MimeTypes.cpp.
240 {
241 const std::map<std::string, std::string>::iterator it =
mimeType.find(std::filesystem::path(file).extension());
242
243 std::string type;
244
246 type = it->second;
247 }
248#ifdef HAS_LIBMAGIC
249 else if (magic != nullptr) {
250 const char* magicType = magic_file(MimeTypes::magic, file.c_str());
251 type = magicType != nullptr ? magicType : std::string();
252 }
253#endif
254
255 return !type.empty() ? type : "application/octet-stream";
256 }
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: