3#include <boost/beast/http/message.hpp>
4#include <boost/beast/http/rfc7230.hpp>
5#include <boost/range/algorithm/equal.hpp>
6#include <boost/range/iterator_range.hpp>
7#include <boost/utility/string_ref.hpp>
28 return std::tolower(
static_cast<unsigned char>(c1)) == std::tolower(
static_cast<unsigned char>(c2));
39 return c ==
' ' || c ==
'\t';
59template <
class FwdIter>
70 }
while (last != first);
74template <
class String>
101split(FwdIt first, FwdIt last, Char delim)
103 using namespace detail;
104 using string =
typename Result::value_type;
129 e.append(1, *iter++);
134 e.append(1, *iter++);
139 result.emplace_back(std::move(e));
143 else if (*iter == delim)
148 result.emplace_back(std::move(e));
153 else if (is_lws(*iter))
159 e.append(1, *iter++);
167 result.emplace_back(std::move(e));
172template <class FwdIt, class Result = std::vector<std::basic_string<typename std::iterator_traits<FwdIt>::value_type>>>
176 return split(first, last,
',');
179template <
class Result = std::vector<std::
string>>
226 return !(*
this == other);
257 template <
class =
void>
266 using namespace detail;
297 else if (*
it_ ==
',')
302 else if (is_lws(*
it_))
327ci_equal(boost::string_ref s1, boost::string_ref s2)
333inline boost::iterator_range<list_iterator>
336 return boost::iterator_range<list_iterator>{
344template <
class =
void>
346token_in_list(boost::string_ref
const& value, boost::string_ref
const& token)
348 for (
auto const& item :
make_list(value))
354template <
bool isRequest,
class Body,
class Fields>
358 if (m.version() <= 10)
359 return boost::beast::http::token_list{m[boost::beast::http::field::connection]}.exists(
"keep-alive");
360 return !boost::beast::http::token_list{m[boost::beast::http::field::connection]}.exists(
"close");
Iterates through a comma separated list.
pointer operator->() const
boost::string_ref::const_iterator iter_type
value_type const * pointer
list_iterator(iter_type begin, iter_type end)
boost::string_ref value_type
bool operator!=(list_iterator const &other) const
reference operator*() const
list_iterator & operator++()
bool operator==(list_iterator const &other) const
value_type const & reference
list_iterator operator++(int)
bool is_white(char c)
Returns true if c is any whitespace character.
bool is_lws(char c)
Returns true if c is linear white space.
FwdIter trim_right(FwdIter first, FwdIter last)
boost::iterator_range< list_iterator > make_list(boost::string_ref const &field)
Returns a range representing the list.
Result split_commas(FwdIt first, FwdIt last)
Result split(FwdIt first, FwdIt last, Char delim)
Parse a character sequence of values separated by commas.
bool is_keep_alive(boost::beast::http::message< isRequest, Body, Fields > const &m)
bool ci_equal(boost::string_ref s1, boost::string_ref s2)
Returns true if two strings are equal.
bool token_in_list(boost::string_ref const &value, boost::string_ref const &token)
Returns true if the specified token exists in the list.
field_t< CharT, Traits, Allocator > field(std::basic_string< CharT, Traits, Allocator > const &text, int width=8, int pad=0, bool right=false)
bool operator()(char c1, char c2)