mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 21:07:26 +02:00
Tidy up basic_parser:
- Add const qualifiers. - Fix parser conversion constructor not copying header_limit_ and status_ fields. - Use default special member functions when possible. - Zero-initialize non-class members. Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
This commit is contained in:
committed by
Vinnie Falco
parent
f96785df4f
commit
0f7670b7e0
@ -3,6 +3,7 @@ Version 140:
|
|||||||
* Fix some integer warnings in 64-bit builds
|
* Fix some integer warnings in 64-bit builds
|
||||||
* Fix utf8_checker test failures
|
* Fix utf8_checker test failures
|
||||||
* Fix signature for async_read_some, and tests
|
* Fix signature for async_read_some, and tests
|
||||||
|
* Tidy up basic_parser
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ class basic_parser
|
|||||||
static unsigned constexpr flagUpgrade = 1<< 12;
|
static unsigned constexpr flagUpgrade = 1<< 12;
|
||||||
static unsigned constexpr flagFinalChunk = 1<< 13;
|
static unsigned constexpr flagFinalChunk = 1<< 13;
|
||||||
|
|
||||||
static
|
static constexpr
|
||||||
std::uint64_t
|
std::uint64_t
|
||||||
default_body_limit(std::true_type)
|
default_body_limit(std::true_type)
|
||||||
{
|
{
|
||||||
@ -211,7 +211,7 @@ class basic_parser
|
|||||||
return 1 * 1024 * 1024; // 1MB
|
return 1 * 1024 * 1024; // 1MB
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static constexpr
|
||||||
std::uint64_t
|
std::uint64_t
|
||||||
default_body_limit(std::false_type)
|
default_body_limit(std::false_type)
|
||||||
{
|
{
|
||||||
@ -219,17 +219,16 @@ class basic_parser
|
|||||||
return 8 * 1024 * 1024; // 8MB
|
return 8 * 1024 * 1024; // 8MB
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t body_limit_; // max payload body
|
std::uint64_t body_limit_ =
|
||||||
std::uint64_t len_; // size of chunk or body
|
default_body_limit(is_request{}); // max payload body
|
||||||
std::unique_ptr<char[]> buf_; // temp storage
|
std::uint64_t len_ = 0; // size of chunk or body
|
||||||
std::size_t buf_len_ = 0; // size of buf_
|
std::unique_ptr<char[]> buf_; // temp storage
|
||||||
std::size_t skip_ = 0; // resume search here
|
std::size_t buf_len_ = 0; // size of buf_
|
||||||
std::uint32_t
|
std::size_t skip_ = 0; // resume search here
|
||||||
header_limit_ = 8192; // max header size
|
std::uint32_t header_limit_ = 8192; // max header size
|
||||||
unsigned short status_; // response status
|
unsigned short status_ = 0; // response status
|
||||||
state state_ = // initial state
|
state state_ = state::nothing_yet; // initial state
|
||||||
state::nothing_yet;
|
unsigned f_ = 0; // flags
|
||||||
unsigned f_ = 0; // flags
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// `true` if this parser parses requests, `false` for responses.
|
/// `true` if this parser parses requests, `false` for responses.
|
||||||
@ -237,16 +236,22 @@ public:
|
|||||||
std::integral_constant<bool, isRequest>;
|
std::integral_constant<bool, isRequest>;
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~basic_parser();
|
~basic_parser() = default;
|
||||||
|
|
||||||
/// Constructor
|
/// Copy constructor
|
||||||
basic_parser(basic_parser const&) = delete;
|
basic_parser(basic_parser const&) = delete;
|
||||||
|
|
||||||
/// Constructor
|
/// Move constructor
|
||||||
|
basic_parser(basic_parser &&) = default;
|
||||||
|
|
||||||
|
/// Move assignment
|
||||||
|
basic_parser& operator=(basic_parser &&) = default;
|
||||||
|
|
||||||
|
/// Copy assignment
|
||||||
basic_parser& operator=(basic_parser const&) = delete;
|
basic_parser& operator=(basic_parser const&) = delete;
|
||||||
|
|
||||||
/// Constructor
|
/// Default constructor
|
||||||
basic_parser();
|
basic_parser() = default;
|
||||||
|
|
||||||
/** Move constructor
|
/** Move constructor
|
||||||
|
|
||||||
@ -457,7 +462,7 @@ public:
|
|||||||
|
|
||||||
/// Returns `true` if the skip parse option is set.
|
/// Returns `true` if the skip parse option is set.
|
||||||
bool
|
bool
|
||||||
skip()
|
skip() const
|
||||||
{
|
{
|
||||||
return (f_ & flagSkipBody) != 0;
|
return (f_ & flagSkipBody) != 0;
|
||||||
}
|
}
|
||||||
|
@ -25,20 +25,6 @@ namespace boost {
|
|||||||
namespace beast {
|
namespace beast {
|
||||||
namespace http {
|
namespace http {
|
||||||
|
|
||||||
template<bool isRequest, class Derived>
|
|
||||||
basic_parser<isRequest, Derived>::
|
|
||||||
~basic_parser()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template<bool isRequest, class Derived>
|
|
||||||
basic_parser<isRequest, Derived>::
|
|
||||||
basic_parser()
|
|
||||||
: body_limit_(
|
|
||||||
default_body_limit(is_request{}))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template<bool isRequest, class Derived>
|
template<bool isRequest, class Derived>
|
||||||
template<class OtherDerived>
|
template<class OtherDerived>
|
||||||
basic_parser<isRequest, Derived>::
|
basic_parser<isRequest, Derived>::
|
||||||
@ -49,6 +35,8 @@ basic_parser(basic_parser<
|
|||||||
, buf_(std::move(other.buf_))
|
, buf_(std::move(other.buf_))
|
||||||
, buf_len_(other.buf_len_)
|
, buf_len_(other.buf_len_)
|
||||||
, skip_(other.skip_)
|
, skip_(other.skip_)
|
||||||
|
, header_limit_(other.header_limit_)
|
||||||
|
, status_(other.status_)
|
||||||
, state_(other.state_)
|
, state_(other.state_)
|
||||||
, f_(other.f_)
|
, f_(other.f_)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user