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>
27 return std::tolower(
static_cast<unsigned char>(c1)) ==
28 std::tolower(
static_cast<unsigned char>(c2));
39 return c ==
' ' || c ==
'\t';
60template <
class FwdIter>
71 }
while (last != first);
75template <
class String>
102split(FwdIt first, FwdIt last, Char delim)
105 using string = Result::value_type;
130 e.append(1, *iter++);
135 e.append(1, *iter++);
140 result.emplace_back(std::move(e));
144 else if (*iter == delim)
149 result.emplace_back(std::move(e));
154 else if (isLws(*iter))
160 e.append(1, *iter++);
168 result.emplace_back(std::move(e));
179 return split(first, last,
',');
182template <
class Result = std::vector<std::
string>>
229 return !(*
this == other);
260 template <
class =
void>
300 else if (*
it_ ==
',')
305 else if (isLws(*
it_))
330ciEqual(boost::string_ref s1, boost::string_ref s2)
336inline boost::iterator_range<ListIterator>
339 return boost::iterator_range<ListIterator>{
347template <
class =
void>
349tokenInList(boost::string_ref
const& value, boost::string_ref
const& token)
351 for (
auto const& item :
makeList(value))
359template <
bool IsRequest,
class Body,
class Fields>
361isKeepAlive(boost::beast::http::message<IsRequest, Body, Fields>
const& m)
363 if (m.version() <= 10)
365 return boost::beast::http::token_list{m[boost::beast::http::field::connection]}.exists(
368 return !boost::beast::http::token_list{m[boost::beast::http::field::connection]}.exists(
Iterates through a comma separated list.
ListIterator operator++(int)
pointer operator->() const
reference operator*() const
bool operator==(ListIterator const &other) const
ListIterator(iter_type begin, iter_type end)
value_type const & reference
std::forward_iterator_tag iterator_category
ListIterator & operator++()
boost::string_ref::const_iterator iter_type
value_type const * pointer
bool operator!=(ListIterator const &other) const
std::ptrdiff_t difference_type
boost::string_ref value_type
FwdIter trimRight(FwdIter first, FwdIter last)
bool isLws(char c)
Returns true if c is linear white space.
bool isWhite(char c)
Returns true if c is any whitespace character.
bool isKeepAlive(boost::beast::http::message< IsRequest, Body, Fields > const &m)
boost::iterator_range< ListIterator > makeList(boost::string_ref const &field)
Returns a range representing the list.
Result split(FwdIt first, FwdIt last, Char delim)
Parse a character sequence of values separated by commas.
Result splitCommas(FwdIt first, FwdIt last)
bool ciEqual(boost::string_ref s1, boost::string_ref s2)
Returns true if two strings are equal.
bool tokenInList(boost::string_ref const &value, boost::string_ref const &token)
Returns true if the specified token exists in the list.
FieldT< 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)