mime_types.cpp

来自「Boost provides free peer-reviewed portab」· C++ 代码 · 共 47 行

CPP
47
字号
//// mime_types.cpp// ~~~~~~~~~~~~~~//// Copyright (c) 2003-2008 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" },  { 0, 0 } // Marks end of list.};std::string extension_to_type(const std::string& extension){  for (mapping* m = mappings; m->extension; ++m)  {    if (m->extension == extension)    {      return m->mime_type;    }  }  return "text/plain";}} // namespace mime_types} // namespace server} // namespace http

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?