]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/asio/example/cpp03/http/server4/mime_types.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / asio / example / cpp03 / http / server4 / mime_types.cpp
CommitLineData
7c673cae
FG
1//
2// mime_types.cpp
3// ~~~~~~~~~~~~~~
4//
b32b8144 5// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7c673cae
FG
6//
7// Distributed under the Boost Software License, Version 1.0. (See accompanying
8// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9//
10
11#include "mime_types.hpp"
12
13namespace http {
14namespace server4 {
15namespace mime_types {
16
17struct mapping
18{
19 const char* extension;
20 const char* mime_type;
21} mappings[] =
22{
23 { "gif", "image/gif" },
24 { "htm", "text/html" },
25 { "html", "text/html" },
26 { "jpg", "image/jpeg" },
27 { "png", "image/png" },
28 { 0, 0 } // Marks end of list.
29};
30
31std::string extension_to_type(const std::string& extension)
32{
33 for (mapping* m = mappings; m->extension; ++m)
34 {
35 if (m->extension == extension)
36 {
37 return m->mime_type;
38 }
39 }
40
41 return "text/plain";
42}
43
44} // namespace mime_types
45} // namespace server4
46} // namespace http