rfc7230.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/beast
  8. //
  9. #ifndef BOOST_BEAST_HTTP_DETAIL_RFC7230_HPP
  10. #define BOOST_BEAST_HTTP_DETAIL_RFC7230_HPP
  11. #include <boost/beast/core/string.hpp>
  12. #include <iterator>
  13. #include <utility>
  14. namespace boost {
  15. namespace beast {
  16. namespace http {
  17. namespace detail {
  18. BOOST_BEAST_DECL
  19. bool
  20. is_digit(char c);
  21. BOOST_BEAST_DECL
  22. char
  23. is_alpha(char c);
  24. BOOST_BEAST_DECL
  25. char
  26. is_text(char c);
  27. BOOST_BEAST_DECL
  28. char
  29. is_token_char(char c);
  30. BOOST_BEAST_DECL
  31. char
  32. is_qdchar(char c);
  33. BOOST_BEAST_DECL
  34. char
  35. is_qpchar(char c);
  36. // converts to lower case,
  37. // returns 0 if not a valid text char
  38. //
  39. BOOST_BEAST_DECL
  40. char
  41. to_value_char(char c);
  42. // VFALCO TODO Make this return unsigned?
  43. BOOST_BEAST_DECL
  44. std::int8_t
  45. unhex(char c);
  46. BOOST_BEAST_DECL
  47. void
  48. skip_ows(char const*& it, char const* end);
  49. BOOST_BEAST_DECL
  50. void
  51. skip_token(char const*& it, char const* last);
  52. BOOST_BEAST_DECL
  53. string_view
  54. trim(string_view s);
  55. struct param_iter
  56. {
  57. using iter_type = string_view::const_iterator;
  58. iter_type it;
  59. iter_type first;
  60. iter_type last;
  61. std::pair<string_view, string_view> v;
  62. bool
  63. empty() const
  64. {
  65. return first == it;
  66. }
  67. BOOST_BEAST_DECL
  68. void
  69. increment();
  70. };
  71. /*
  72. #token = [ ( "," / token ) *( OWS "," [ OWS token ] ) ]
  73. */
  74. struct opt_token_list_policy
  75. {
  76. using value_type = string_view;
  77. BOOST_BEAST_DECL
  78. bool
  79. operator()(value_type& v,
  80. char const*& it, string_view s) const;
  81. };
  82. } // detail
  83. } // http
  84. } // beast
  85. } // boost
  86. #ifdef BOOST_BEAST_HEADER_ONLY
  87. #include <boost/beast/http/detail/rfc7230.ipp>
  88. #endif
  89. #endif