| Home | Libraries | People | FAQ | More

# http/server/mime_types.cpp

Go to the documentation of this file.

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

| Copyright © 2003 - 2006 Christopher M. Kohlhoff