diff options
Diffstat (limited to '3rdparty/asio/src/examples/cpp11/http/server/mime_types.cpp')
-rw-r--r-- | 3rdparty/asio/src/examples/cpp11/http/server/mime_types.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/3rdparty/asio/src/examples/cpp11/http/server/mime_types.cpp b/3rdparty/asio/src/examples/cpp11/http/server/mime_types.cpp new file mode 100644 index 00000000000..a59955e8d5b --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/http/server/mime_types.cpp @@ -0,0 +1,45 @@ +// +// mime_types.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2021 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" }, + { "png", "image/png" } +}; + +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 |