File indexing completed on 2025-01-18 09:29:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_BEAST_HTTP_DETAIL_BASIC_PARSER_HPP
0011 #define BOOST_BEAST_HTTP_DETAIL_BASIC_PARSER_HPP
0012
0013 #include <boost/beast/core/string.hpp>
0014 #include <boost/beast/core/detail/char_buffer.hpp>
0015 #include <boost/beast/http/error.hpp>
0016 #include <boost/beast/http/detail/rfc7230.hpp>
0017 #include <boost/config.hpp>
0018 #include <boost/version.hpp>
0019 #include <cstddef>
0020 #include <utility>
0021
0022 namespace boost {
0023 namespace beast {
0024 namespace http {
0025 namespace detail {
0026
0027 struct basic_parser_base
0028 {
0029
0030
0031
0032
0033 static std::size_t constexpr max_obs_fold = 4096;
0034
0035 enum class state
0036 {
0037 nothing_yet = 0,
0038 start_line,
0039 fields,
0040 body0,
0041 body,
0042 body_to_eof0,
0043 body_to_eof,
0044 chunk_header0,
0045 chunk_header,
0046 chunk_body,
0047 complete
0048 };
0049
0050 static
0051 bool
0052 is_digit(char c)
0053 {
0054 return static_cast<unsigned char>(c-'0') < 10;
0055 }
0056
0057 static
0058 bool
0059 is_print(char c)
0060 {
0061 return static_cast<unsigned char>(c-32) < 95;
0062 }
0063
0064 BOOST_BEAST_DECL
0065 static
0066 char const*
0067 trim_front(char const* it, char const* end);
0068
0069 BOOST_BEAST_DECL
0070 static
0071 char const*
0072 trim_back(
0073 char const* it, char const* first);
0074
0075 static
0076 string_view
0077 make_string(char const* first, char const* last)
0078 {
0079 return {first, static_cast<
0080 std::size_t>(last - first)};
0081 }
0082
0083
0084
0085 BOOST_BEAST_DECL
0086 static
0087 bool
0088 is_pathchar(char c);
0089
0090 BOOST_BEAST_DECL
0091 static
0092 bool
0093 unhex(unsigned char& d, char c);
0094
0095 BOOST_BEAST_DECL
0096 static
0097 std::pair<char const*, bool>
0098 find_fast(
0099 char const* buf,
0100 char const* buf_end,
0101 char const* ranges,
0102 size_t ranges_size);
0103
0104 BOOST_BEAST_DECL
0105 static
0106 char const*
0107 find_eol(
0108 char const* it, char const* last,
0109 error_code& ec);
0110
0111 BOOST_BEAST_DECL
0112 static
0113 char const*
0114 find_eom(char const* p, char const* last);
0115
0116
0117
0118 BOOST_BEAST_DECL
0119 static
0120 char const*
0121 parse_token_to_eol(
0122 char const* p,
0123 char const* last,
0124 char const*& token_last,
0125 error_code& ec);
0126
0127 BOOST_BEAST_DECL
0128 static
0129 bool
0130 parse_dec(string_view s, std::uint64_t& v);
0131
0132 BOOST_BEAST_DECL
0133 static
0134 bool
0135 parse_hex(char const*& it, std::uint64_t& v);
0136
0137 BOOST_BEAST_DECL
0138 static
0139 bool
0140 parse_crlf(char const*& it);
0141
0142 BOOST_BEAST_DECL
0143 static
0144 void
0145 parse_method(
0146 char const*& it, char const* last,
0147 string_view& result, error_code& ec);
0148
0149 BOOST_BEAST_DECL
0150 static
0151 void
0152 parse_target(
0153 char const*& it, char const* last,
0154 string_view& result, error_code& ec);
0155
0156 BOOST_BEAST_DECL
0157 static
0158 void
0159 parse_version(
0160 char const*& it, char const* last,
0161 int& result, error_code& ec);
0162
0163 BOOST_BEAST_DECL
0164 static
0165 void
0166 parse_status(
0167 char const*& it, char const* last,
0168 unsigned short& result, error_code& ec);
0169
0170 BOOST_BEAST_DECL
0171 static
0172 void
0173 parse_reason(
0174 char const*& it, char const* last,
0175 string_view& result, error_code& ec);
0176
0177 BOOST_BEAST_DECL
0178 static
0179 void
0180 parse_field(
0181 char const*& p,
0182 char const* last,
0183 string_view& name,
0184 string_view& value,
0185 beast::detail::char_buffer<max_obs_fold>& buf,
0186 error_code& ec);
0187
0188 BOOST_BEAST_DECL
0189 static
0190 void
0191 parse_chunk_extensions(
0192 char const*& it,
0193 char const* last,
0194 error_code& ec);
0195 };
0196
0197 }
0198 }
0199 }
0200 }
0201
0202 #ifdef BOOST_BEAST_HEADER_ONLY
0203 #include <boost/beast/http/detail/basic_parser.ipp>
0204 #endif
0205
0206 #endif