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>
54 return std::tolower(
static_cast<unsigned char>(c1)) ==
55 std::tolower(
static_cast<unsigned char>(c2));
69 return c ==
' ' || c ==
'\t';
79 case ' ':
case '\f':
case '\n':
80 case '\r':
case '\t':
case '\v':
91 return c <= 31 || c >= 127;
102 case '(':
case ')':
case '<':
case '>':
case '@':
103 case ',':
case ';':
case ':':
case '\\':
case '"':
104 case '{':
case '}':
case ' ':
case '\t':
115 #ifdef __CHAR_UNSIGNED__
116 return c >= 0 && c <= 127;
122 template <
class FwdIter>
130 template <
class FwdIter>
142 while (last != first);
146 template <
class CharT,
class Traits,
class Allocator>
149 CharT, Traits, Allocator>& s)
155 template <
class FwdIter>
157 trim (FwdIter first, FwdIter last)
164 template <
class String>
170 auto first = begin(s);
173 return { first, last };
176 template <
class String>
182 auto first (begin(s));
185 return { first, last };
192 return trim <std::string> (s);
203 template <
class FwdIt,
209 split(FwdIt first, FwdIt last, Char delim)
212 using string =
typename Result::value_type;
234 e.append (1, *iter++);
239 e.append (1, *iter++);
244 result.emplace_back(std::move(e));
248 else if (*iter == delim)
253 result.emplace_back(std::move(e));
264 e.append (1, *iter++);
272 result.emplace_back(std::move(e));
277 template <
class FwdIt,
280 FwdIt>::value_type>>>
284 return split(first, last,
',');
287 template <
class Result = std::vector<std::
string>>
338 return !(*
this == other);
369 template<
class =
void>
395 value_ = boost::string_ref(
401 value_ = boost::string_ref(
430 value_ = boost::string_ref(
445 ci_equal(boost::string_ref s1, boost::string_ref s2)
447 return boost::range::equal(s1, s2,
453 boost::iterator_range<list_iterator>
456 return boost::iterator_range<list_iterator>{
465 template<
class =
void>
468 boost::string_ref
const& token)
476 template<
bool isRequest,
class Body,
class Fields>
478 is_keep_alive(boost::beast::http::message<isRequest, Body, Fields>
const& m)
480 if(m.version() <= 10)
481 return boost::beast::http::token_list{
482 m[boost::beast::http::field::connection]}.exists(
"keep-alive");
483 return ! boost::beast::http::token_list{
484 m[boost::beast::http::field::connection]}.exists(
"close");
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