I create http::response_parser<http::buffer_body> and set header_limit and body_limit like this
auto parser = std::make_shared<http::response_parser<http::buffer_body>>();
parser->header_limit(std::numeric_limits<std::uint32_t>::max());
parser->body_limit(std::numeric_limits<std::uint64_t>::max());
Next, I transform the http::response_parser<http::buffer_body> parser into a parser of type http::response_parser<http::string_body> as follows
auto new_parser = std::make_shared<http::response_parser<http::string_body>>(std::move(*parser));
My question is, will new_parser inherit header_limit and body_limit from the original parser or not? I didn't find any methods that could report the current values of the given limits.
Yes. The limits are part of basic_parser<> which defines only defaulted move and assignment.
It's also possible to test, using the friend-ness of basic_parser_test:
Live On Coliru
#include <boost/beast.hpp>
namespace boost::beast::http {
class basic_parser_test {
public:
static void foo() {
auto parser = std::make_shared<http::response_parser<http::buffer_body>>();
parser->header_limit(std::numeric_limits<std::uint32_t>::max());
parser->body_limit(std::numeric_limits<std::uint64_t>::max());
auto new_parser = std::make_shared<http::response_parser<http::string_body>>(std::move(*parser));
assert(new_parser->body_limit_ == std::numeric_limits<std::uint64_t>::max());
assert(new_parser->header_limit_ == std::numeric_limits<std::uint32_t>::max());
}
};
} // namespace boost::beast::http
int main() {
boost::beast::http::basic_parser_test::foo();
}
All asserts pass.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With