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>
55 return std::tolower(
static_cast<unsigned char>(c1)) ==
56 std::tolower(
static_cast<unsigned char>(c2));
69 return c ==
' ' || c ==
'\t';
93 return c <= 31 || c >= 127;
126 #ifdef __CHAR_UNSIGNED__
127 return c >= 0 && c <= 127;
133 template <
class FwdIter>
140 template <
class FwdIter>
151 }
while (last != first);
155 template <
class CharT,
class Traits,
class Allocator>
162 template <
class FwdIter>
164 trim(FwdIter first, FwdIter last)
171 template <
class String>
177 auto first = begin(s);
180 return {first, last};
183 template <
class String>
189 auto first(begin(s));
192 return {first, last};
198 return trim<std::string>(s);
215 split(FwdIt first, FwdIt last, Char delim)
218 using string =
typename Result::value_type;
240 e.append(1, *iter++);
245 e.append(1, *iter++);
250 result.emplace_back(std::move(e));
254 else if (*iter == delim)
259 result.emplace_back(std::move(e));
270 e.append(1, *iter++);
278 result.emplace_back(std::move(e));
290 return split(first, last,
',');
293 template <
class Result = std::vector<std::
string>>
341 return !(*
this == other);
372 template <
class =
void>
398 value_ = boost::string_ref(
404 value_ = boost::string_ref(
413 else if (*
it_ ==
',')
445 ci_equal(boost::string_ref s1, boost::string_ref s2)
451 inline boost::iterator_range<list_iterator>
454 return boost::iterator_range<list_iterator>{
463 template <
class =
void>
465 token_in_list(boost::string_ref
const& value, boost::string_ref
const& token)
467 for (
auto const& item :
make_list(value))
473 template <
bool isRequest,
class Body,
class Fields>
475 is_keep_alive(boost::beast::http::message<isRequest, Body, Fields>
const& m)
477 if (m.version() <= 10)
478 return boost::beast::http::token_list{
479 m[boost::beast::http::field::connection]}
480 .exists(
"keep-alive");
481 return !boost::beast::http::token_list{
482 m[boost::beast::http::field::connection]}
boost::string_ref value_type
value_type const & reference
value_type const * pointer
void trim_right_in_place(std::basic_string< CharT, Traits, Allocator > &s)
bool is_char(char c)
Returns true if c is a character.
bool operator==(list_iterator const &other) const
Result split(FwdIt first, FwdIt last, Char delim)
Parse a character sequence of values separated by commas.
boost::iterator_range< list_iterator > make_list(boost::string_ref const &field)
Returns a range representing the list.
bool operator()(char c1, char c2)
FwdIter trim_right(FwdIter first, FwdIter last)
std::pair< FwdIter, FwdIter > trim(FwdIter first, FwdIter last)
bool is_keep_alive(boost::beast::http::message< isRequest, Body, Fields > const &m)
list_iterator(iter_type begin, iter_type end)
pointer operator->() const
FwdIter trim_left(FwdIter first, FwdIter last)
Iterates through a comma separated list.
bool is_lws(char c)
Returns true if c is linear white space.
Result split_commas(FwdIt first, FwdIt last)
bool is_separator(char c)
Returns true if c is a separator.
bool ci_equal(boost::string_ref s1, boost::string_ref s2)
Returns true if two strings are equal.
reference operator*() const
field_t< CharT, Traits, Allocator > field(std::basic_string< CharT, Traits, Allocator > const &text, int width=8, int pad=0, bool right=false)
bool token_in_list(boost::string_ref const &value, boost::string_ref const &token)
Returns true if the specified token exists in the list.
list_iterator operator++(int)
boost::string_ref::const_iterator iter_type
bool is_white(char c)
Returns true if c is any whitespace character.
bool is_control(char c)
Returns true if c is a control character.
list_iterator & operator++()
bool operator!=(list_iterator const &other) const