2018-08-25 18:23:54 +00:00
|
|
|
//
|
|
|
|
// mime_types.cpp
|
|
|
|
// ~~~~~~~~~~~~~~
|
|
|
|
//
|
|
|
|
// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "mime_types.hpp"
|
|
|
|
|
|
|
|
namespace http {
|
|
|
|
namespace server {
|
|
|
|
namespace mime_types {
|
|
|
|
|
|
|
|
struct mapping
|
|
|
|
{
|
|
|
|
const char* extension;
|
|
|
|
const char* mime_type;
|
|
|
|
} mappings[] =
|
|
|
|
{
|
|
|
|
{ "gif", "image/gif" },
|
|
|
|
{ "htm", "text/html" },
|
|
|
|
{ "html", "text/html" },
|
|
|
|
{ "jpg", "image/jpeg" },
|
2018-08-26 11:32:48 +00:00
|
|
|
{ "png", "image/png" },
|
|
|
|
{"css", "text/css"},
|
|
|
|
{"js", "application/javascript"},
|
|
|
|
{"eot", "application/vnd.ms-fontobject"},
|
|
|
|
{"ttf", "font/ttf"},
|
|
|
|
{"otf", "font/otf"},
|
|
|
|
{"svg", "image/svg+xml"}
|
2018-08-25 18:23:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
std::string extension_to_type(const std::string& extension)
|
|
|
|
{
|
|
|
|
for (mapping m: mappings)
|
|
|
|
{
|
|
|
|
if (m.extension == extension)
|
|
|
|
{
|
|
|
|
return m.mime_type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return "text/plain";
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace mime_types
|
|
|
|
} // namespace server
|
|
|
|
} // namespace http
|