10 #ifndef BOOST_BEAST_HTTP_BASIC_PARSER_HPP 11 #define BOOST_BEAST_HTTP_BASIC_PARSER_HPP 19 #include <boost/asio/buffer.hpp> 20 #include <boost/optional.hpp> 21 #include <boost/assert.hpp> 24 #include <type_traits> 171 template<
bool isRequest,
class Derived>
175 template<
bool OtherIsRequest,
class OtherDerived>
179 static std::size_t constexpr max_stack_buffer = 8192;
182 static unsigned constexpr flagSkipBody = 1<< 0;
185 static unsigned constexpr flagEager = 1<< 1;
188 static unsigned constexpr flagGotSome = 1<< 2;
193 static unsigned constexpr flagHasBody = 1<< 3;
195 static unsigned constexpr flagHTTP11 = 1<< 4;
196 static unsigned constexpr flagNeedEOF = 1<< 5;
197 static unsigned constexpr flagExpectCRLF = 1<< 6;
198 static unsigned constexpr flagConnectionClose = 1<< 7;
199 static unsigned constexpr flagConnectionUpgrade = 1<< 8;
200 static unsigned constexpr flagConnectionKeepAlive = 1<< 9;
201 static unsigned constexpr flagContentLength = 1<< 10;
202 static unsigned constexpr flagChunked = 1<< 11;
203 static unsigned constexpr flagUpgrade = 1<< 12;
204 static unsigned constexpr flagFinalChunk = 1<< 13;
208 default_body_limit(std::true_type)
211 return 1 * 1024 * 1024;
216 default_body_limit(std::false_type)
219 return 8 * 1024 * 1024;
222 std::uint64_t body_limit_;
224 std::unique_ptr<char[]> buf_;
225 std::size_t buf_len_ = 0;
226 std::size_t skip_ = 0;
228 header_limit_ = 8192;
229 unsigned short status_;
237 std::integral_constant<bool, isRequest>;
256 template<
class OtherDerived>
324 return (f_ & flagConnectionUpgrade) != 0;
335 return (f_ & flagChunked) != 0;
351 boost::optional<std::uint64_t>
365 return (f_ & flagNeedEOF) != 0;
427 return (f_ & flagEager) != 0;
459 return (f_ & flagSkipBody) != 0;
512 template<
class ConstBufferSequence>
516 #if ! BOOST_BEAST_DOXYGEN 518 put(boost::asio::const_buffers_1
const& buffer,
546 return *
static_cast<Derived*
>(
this);
549 template<
class ConstBufferSequence>
551 put_from_stack(std::size_t size,
557 char const* p, std::size_t n,
562 char const*& p,
char const* last,
567 char const*& p,
char const* last,
572 char const*& p,
char const* last,
584 parse_body(
char const*& p,
588 parse_body_to_eof(
char const*& p,
592 parse_chunk_header(
char const*& p,
596 parse_chunk_body(
char const*& p,
BufferSequence< boost::asio::const_buffer > ConstBufferSequence
Definition: type_traits.hpp:280
void body_limit(std::uint64_t v)
Definition: basic_parser.hpp:400
std::size_t put(ConstBufferSequence const &buffers, error_code &ec)
Definition: basic_parser.ipp:103
Definition: async_result.hpp:20
field
Definition: field.hpp:21
detail::buffers_helper< ConstBufferSequence > buffers(ConstBufferSequence const &b)
Definition: ostream.hpp:50
basic_parser const & base() const
Definition: basic_parser.hpp:278
bool skip()
Returns true if the skip parse option is set.
Definition: basic_parser.hpp:457
bool is_header_done() const
Definition: basic_parser.hpp:311
bool is_upgrade() const
Definition: basic_parser.hpp:322
Definition: beast_common.hpp:6
void header_limit(std::uint32_t v)
Definition: basic_parser.hpp:418
bool need_eof() const
Definition: basic_parser.hpp:363
bool got_some() const
Returns true if the parser has received at least one byte of input.
Definition: basic_parser.hpp:285
boost::system::error_code error_code
The type of error code used by the library.
Definition: error.hpp:21
state
Definition: basic_parser.hpp:38
bool eager() const
Returns true if the eager parse option is set.
Definition: basic_parser.hpp:425
std::integral_constant< bool, isRequest > is_request
true if this parser parses requests, false for responses.
Definition: basic_parser.hpp:237
basic_parser()
Constructor.
Definition: basic_parser.ipp:36
void eager(bool v)
Definition: basic_parser.hpp:447
basic_parser & operator=(basic_parser const &)=delete
Constructor.
boost::optional< std::uint64_t > content_length() const
Definition: basic_parser.ipp:79
~basic_parser()
Destructor.
Definition: basic_parser.ipp:30
bool is_keep_alive() const
Definition: basic_parser.ipp:60
boost::string_ref string_view
The type of string view used by the library.
Definition: string.hpp:36
bool is_done() const
Definition: basic_parser.hpp:303
bool is_chunked() const
Definition: basic_parser.hpp:333
void put_eof(error_code &ec)
Definition: basic_parser.ipp:290
Definition: basic_parser.hpp:29
basic_parser & base()
Definition: basic_parser.hpp:266
Definition: basic_parser.hpp:172