20#ifndef BEAST_RFC2616_HPP
21#define BEAST_RFC2616_HPP
23#include <boost/beast/http/message.hpp>
24#include <boost/beast/http/rfc7230.hpp>
25#include <boost/range/algorithm/equal.hpp>
26#include <boost/range/iterator_range.hpp>
27#include <boost/utility/string_ref.hpp>
50 return std::tolower(
static_cast<unsigned char>(c1)) ==
51 std::tolower(
static_cast<unsigned char>(c2));
62 return c ==
' ' || c ==
'\t';
82template <
class FwdIter>
93 }
while (last != first);
97template <
class String>
103 auto first(begin(s));
106 return {first, last};
125split(FwdIt first, FwdIt last, Char delim)
127 using namespace detail;
128 using string =
typename Result::value_type;
153 e.append(1, *iter++);
158 e.append(1, *iter++);
163 result.emplace_back(std::move(e));
167 else if (*iter == delim)
172 result.emplace_back(std::move(e));
177 else if (is_lws(*iter))
183 e.append(1, *iter++);
191 result.emplace_back(std::move(e));
203 return split(first, last,
',');
206template <
class Result = std::vector<std::
string>>
254 return !(*
this == other);
285 template <
class =
void>
294 using namespace detail;
312 value_ = boost::string_ref(
318 value_ = boost::string_ref(
327 else if (*
it_ ==
',')
332 else if (is_lws(*
it_))
358ci_equal(boost::string_ref s1, boost::string_ref s2)
364inline boost::iterator_range<list_iterator>
367 return boost::iterator_range<list_iterator>{
376template <
class =
void>
378token_in_list(boost::string_ref
const& value, boost::string_ref
const& token)
380 for (
auto const& item :
make_list(value))
386template <
bool isRequest,
class Body,
class Fields>
390 if (m.version() <= 10)
391 return boost::beast::http::token_list{
392 m[boost::beast::http::field::connection]}
393 .exists(
"keep-alive");
394 return !boost::beast::http::token_list{
395 m[boost::beast::http::field::connection]}
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)