Skip to content

Commit

Permalink
Closes cpp-netlib#313 -- make all client implementations use a non-ca…
Browse files Browse the repository at this point in the history
…se-sensitive multimap.
  • Loading branch information
deanberris committed Nov 24, 2013
1 parent cc25d3e commit f4351ad
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 33 deletions.
51 changes: 26 additions & 25 deletions boost/network/protocol/http/traits/impl/headers_container.ipp
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@

// Copyright Dean Michael Berris 2008.
// Copyright 2013 Google, Inc.
// Copyright 2008 Dean Michael Berris <dberris@google.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)
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_HEADERS_CONTAINER_IPP
#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_HEADERS_CONTAINER_IPP

#include <boost/utility/enable_if.hpp>
#include <boost/network/traits/headers_container.hpp>
#include <boost/network/protocol/http/tags.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <map>
#include <string>

namespace boost { namespace network {

template <>
struct headers_container<http::tags::http_default_8bit_tcp_resolve> {

// Moving implementation from original
// message_traits implementation by
// Atomic Labs, Inc.
// --
// returns true if str1 < str2 (ignoring case)
struct is_less_ignore_case {
inline bool operator() (
string<http::tags::http_default_8bit_tcp_resolve>::type const & str1,
string<http::tags::http_default_8bit_tcp_resolve>::type const & str2) const {
return to_lower_copy(str1) < to_lower_copy(str2);
};
namespace boost { namespace network { namespace impl {

template <class Tag>
struct headers_container_impl<Tag, typename enable_if<typename Tag::is_client>::type> {
// Moving implementation from original
// message_traits implementation by
// Atomic Labs, Inc.
// --
// returns true if str1 < str2 (ignoring case)
struct is_less_ignore_case {
inline bool operator() (
string<http::tags::http_default_8bit_tcp_resolve>::type const & str1,
string<http::tags::http_default_8bit_tcp_resolve>::type const & str2) const {
return to_lower_copy(str1) < to_lower_copy(str2);
};

typedef std::multimap<
string<http::tags::http_default_8bit_tcp_resolve>::type,
string<http::tags::http_default_8bit_tcp_resolve>::type,
is_less_ignore_case> type;
};

} // namespace network
typedef std::multimap<
string<http::tags::http_default_8bit_tcp_resolve>::type,
string<http::tags::http_default_8bit_tcp_resolve>::type,
is_less_ignore_case> type;
};

} // namespace impl
} // namespace network
} // namespace boost

#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_TRAITS_HEADERS_CONTAINER_IPP
Expand Down
23 changes: 15 additions & 8 deletions boost/network/traits/headers_container.hpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
// Copyright (c) Glyn Matthews 2009.
// Copyright (c) Glyn Matthews 2009.
// Copyright 2013 Google, Inc.
// Copyright 2013 Dean Michael Berris <dberris@google.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)
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)


#ifndef __BOOST_NETWORK_TRAITS_HEADERS_CONTAINER_INC__
# define __BOOST_NETWORK_TRAITS_HEADERS_CONTAINER_INC__
#ifndef BOOST_NETWORK_TRAITS_HEADERS_CONTAINER_INC
# define BOOST_NETWORK_TRAITS_HEADERS_CONTAINER_INC

# include <map>
# include <boost/network/tags.hpp>
# include <boost/network/traits/string.hpp>

namespace boost { namespace network {
namespace boost { namespace network { namespace impl {

template <class Tag>
struct headers_container {
template <class Tag, class Enable = void>
struct headers_container_impl {
typedef std::multimap<
typename string<Tag>::type,
typename string<Tag>::type
> type;
};

} // namespace impl

template <class Tag>
struct headers_container : impl::headers_container_impl<Tag> {};

} // namespace network
} // namespace boost

Expand Down

0 comments on commit f4351ad

Please sign in to comment.