]> git.proxmox.com Git - ceph.git/blame - ceph/src/Beast/examples/mime_type.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / Beast / examples / mime_type.hpp
CommitLineData
7c673cae
FG
1//
2// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
3//
4// Distributed under the Boost Software License, Version 1.0. (See accompanying
5// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7
8#ifndef BEAST_EXAMPLE_HTTP_MIME_TYPE_H_INCLUDED
9#define BEAST_EXAMPLE_HTTP_MIME_TYPE_H_INCLUDED
10
11#include <string>
12#include <boost/filesystem/path.hpp>
13
14namespace beast {
15namespace http {
16
17// Return the Mime-Type for a given file extension
18template<class = void>
19std::string
20mime_type(std::string const& path)
21{
22 auto const ext =
23 boost::filesystem::path{path}.extension().string();
24 if(ext == ".txt") return "text/plain";
25 if(ext == ".htm") return "text/html";
26 if(ext == ".html") return "text/html";
27 if(ext == ".php") return "text/html";
28 if(ext == ".css") return "text/css";
29 if(ext == ".js") return "application/javascript";
30 if(ext == ".json") return "application/json";
31 if(ext == ".xml") return "application/xml";
32 if(ext == ".swf") return "application/x-shockwave-flash";
33 if(ext == ".flv") return "video/x-flv";
34 if(ext == ".png") return "image/png";
35 if(ext == ".jpe") return "image/jpeg";
36 if(ext == ".jpeg") return "image/jpeg";
37 if(ext == ".jpg") return "image/jpeg";
38 if(ext == ".gif") return "image/gif";
39 if(ext == ".bmp") return "image/bmp";
40 if(ext == ".ico") return "image/vnd.microsoft.icon";
41 if(ext == ".tiff") return "image/tiff";
42 if(ext == ".tif") return "image/tiff";
43 if(ext == ".svg") return "image/svg+xml";
44 if(ext == ".svgz") return "image/svg+xml";
45 return "application/text";
46}
47
48} // http
49} // beast
50
51#endif