Sha256: c13f98533093738a90c0ce6df76e1f913bc309f3e89332b303668508ec9fa9e2

Contents?: true

Size: 911 Bytes

Versions: 16

Compression:

Stored size: 911 Bytes

Contents

//
// mime_types.cpp
// ~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2020 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 server4 {
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 server4
} // namespace http

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
couchbase-3.0.0.alpha.4-x86_64-linux ext/third_party/asio/asio/src/examples/cpp03/http/server4/mime_types.cpp
couchbase-3.0.0.alpha.4-x86_64-darwin-19 ext/third_party/asio/asio/src/examples/cpp03/http/server4/mime_types.cpp
couchbase-3.0.0.alpha.4-universal-darwin-19 ext/third_party/asio/asio/src/examples/cpp03/http/server4/mime_types.cpp
couchbase-3.0.0.alpha.4 ext/third_party/asio/asio/src/examples/cpp03/http/server4/mime_types.cpp
couchbase-3.0.0.alpha.3-x86_64-linux ext/third_party/asio/asio/src/examples/cpp03/http/server4/mime_types.cpp
couchbase-3.0.0.alpha.3-x86_64-darwin-19 ext/third_party/asio/asio/src/examples/cpp03/http/server4/mime_types.cpp
couchbase-3.0.0.alpha.3-universal-darwin-19 ext/third_party/asio/asio/src/examples/cpp03/http/server4/mime_types.cpp
couchbase-3.0.0.alpha.3 ext/third_party/asio/asio/src/examples/cpp03/http/server4/mime_types.cpp
couchbase-3.0.0.alpha.2-x86_64-linux ext/third_party/asio/asio/src/examples/cpp03/http/server4/mime_types.cpp
couchbase-3.0.0.alpha.2-x86_64-darwin-19 ext/third_party/asio/asio/src/examples/cpp03/http/server4/mime_types.cpp
couchbase-3.0.0.alpha.2-universal-darwin-19 ext/third_party/asio/asio/src/examples/cpp03/http/server4/mime_types.cpp
couchbase-3.0.0.alpha.2 ext/third_party/asio/asio/src/examples/cpp03/http/server4/mime_types.cpp
couchbase-3.0.0.alpha.1-x86_64-linux ext/third_party/asio/asio/src/examples/cpp03/http/server4/mime_types.cpp
couchbase-3.0.0.alpha.1-x86_64-darwin-19 ext/third_party/asio/asio/src/examples/cpp03/http/server4/mime_types.cpp
couchbase-3.0.0.alpha.1-universal-darwin-19 ext/third_party/asio/asio/src/examples/cpp03/http/server4/mime_types.cpp
couchbase-3.0.0.alpha.1 ext/third_party/asio/asio/src/examples/cpp03/http/server4/mime_types.cpp