00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "mime_types.hpp"
00012
00013 namespace http {
00014 namespace server {
00015 namespace mime_types {
00016
00017 struct mapping
00018 {
00019 const char* extension;
00020 const char* mime_type;
00021 } mappings[] =
00022 {
00023 { "gif", "image/gif" },
00024 { "htm", "text/html" },
00025 { "html", "text/html" },
00026 { "jpg", "image/jpeg" },
00027 { "png", "image/png" },
00028 { 0, 0 }
00029 };
00030
00031 std::string extension_to_type(const std::string& extension)
00032 {
00033 for (mapping* m = mappings; m->extension; ++m)
00034 {
00035 if (m->extension == extension)
00036 {
00037 return m->mime_type;
00038 }
00039 }
00040
00041 return "text/plain";
00042 }
00043
00044 }
00045 }
00046 }