diff --git a/CHANGELOG.md b/CHANGELOG.md index eba7dd4e..76341141 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Version 140: * Fix some integer warnings in 64-bit builds * Fix utf8_checker test failures * Fix signature for async_read_some, and tests +* Tidy up basic_parser -------------------------------------------------------------------------------- diff --git a/include/boost/beast/http/basic_parser.hpp b/include/boost/beast/http/basic_parser.hpp index f9c35f4a..30a7c888 100644 --- a/include/boost/beast/http/basic_parser.hpp +++ b/include/boost/beast/http/basic_parser.hpp @@ -203,7 +203,7 @@ class basic_parser static unsigned constexpr flagUpgrade = 1<< 12; static unsigned constexpr flagFinalChunk = 1<< 13; - static + static constexpr std::uint64_t default_body_limit(std::true_type) { @@ -211,7 +211,7 @@ class basic_parser return 1 * 1024 * 1024; // 1MB } - static + static constexpr std::uint64_t default_body_limit(std::false_type) { @@ -219,17 +219,16 @@ class basic_parser return 8 * 1024 * 1024; // 8MB } - std::uint64_t body_limit_; // max payload body - std::uint64_t len_; // size of chunk or body - std::unique_ptr buf_; // temp storage - std::size_t buf_len_ = 0; // size of buf_ - std::size_t skip_ = 0; // resume search here - std::uint32_t - header_limit_ = 8192; // max header size - unsigned short status_; // response status - state state_ = // initial state - state::nothing_yet; - unsigned f_ = 0; // flags + std::uint64_t body_limit_ = + default_body_limit(is_request{}); // max payload body + std::uint64_t len_ = 0; // size of chunk or body + std::unique_ptr buf_; // temp storage + std::size_t buf_len_ = 0; // size of buf_ + std::size_t skip_ = 0; // resume search here + std::uint32_t header_limit_ = 8192; // max header size + unsigned short status_ = 0; // response status + state state_ = state::nothing_yet; // initial state + unsigned f_ = 0; // flags public: /// `true` if this parser parses requests, `false` for responses. @@ -237,16 +236,22 @@ public: std::integral_constant; /// Destructor - ~basic_parser(); + ~basic_parser() = default; - /// Constructor + /// Copy constructor 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; - /// Constructor - basic_parser(); + /// Default constructor + basic_parser() = default; /** Move constructor @@ -457,7 +462,7 @@ public: /// Returns `true` if the skip parse option is set. bool - skip() + skip() const { return (f_ & flagSkipBody) != 0; } diff --git a/include/boost/beast/http/impl/basic_parser.ipp b/include/boost/beast/http/impl/basic_parser.ipp index 1930ae23..355a76fb 100644 --- a/include/boost/beast/http/impl/basic_parser.ipp +++ b/include/boost/beast/http/impl/basic_parser.ipp @@ -25,20 +25,6 @@ namespace boost { namespace beast { namespace http { -template -basic_parser:: -~basic_parser() -{ -} - -template -basic_parser:: -basic_parser() - : body_limit_( - default_body_limit(is_request{})) -{ -} - template template basic_parser:: @@ -49,6 +35,8 @@ basic_parser(basic_parser< , buf_(std::move(other.buf_)) , buf_len_(other.buf_len_) , skip_(other.skip_) + , header_limit_(other.header_limit_) + , status_(other.status_) , state_(other.state_) , f_(other.f_) {