diff --git a/CHANGELOG.md b/CHANGELOG.md index c0524ebf..38121340 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * Tidy up basic_headers for documentation * Tidy up documentation * Add basic_parser_v1::reset +* Fix handling of body_what::pause in basic_parser_v1 API Changes: diff --git a/include/beast/http/basic_parser_v1.hpp b/include/beast/http/basic_parser_v1.hpp index 0b056d7d..039a42c1 100644 --- a/include/beast/http/basic_parser_v1.hpp +++ b/include/beast/http/basic_parser_v1.hpp @@ -422,7 +422,10 @@ public: bool complete() const { - return s_ == s_restart || s_ == s_closed_complete; + return + s_ == s_restart || + s_ == s_closed_complete || + s_ == s_body_pause; } /** Write a sequence of buffers to the parser. diff --git a/include/beast/http/detail/basic_parser_v1.hpp b/include/beast/http/detail/basic_parser_v1.hpp index d6e0f3ae..30f9e7be 100644 --- a/include/beast/http/detail/basic_parser_v1.hpp +++ b/include/beast/http/detail/basic_parser_v1.hpp @@ -127,7 +127,7 @@ protected: s_chunk_data_cr, s_chunk_data_lf, - s_body_what, + s_body_pause, s_body_identity0, s_body_identity, s_body_identity_eof0, diff --git a/include/beast/http/impl/basic_parser_v1.ipp b/include/beast/http/impl/basic_parser_v1.ipp index 4793fe75..a610a20b 100644 --- a/include/beast/http/impl/basic_parser_v1.ipp +++ b/include/beast/http/impl/basic_parser_v1.ipp @@ -902,11 +902,29 @@ write(boost::asio::const_buffer const& buffer, error_code& ec) call_on_headers(ec); if(ec) return errc(); - s_ = s_body_what; - // fall through + auto const what = call_on_body_what(ec); + if(ec) + return errc(); + switch(what) + { + case body_what::normal: + break; + case body_what::upgrade: + upgrade_ = true; + // fall through + case body_what::skip: + flags_ |= parse_flag::skipbody; + break; + case body_what::pause: + ++p; + s_ = s_body_pause; + return used(); + } + s_ = s_headers_done; + goto redo; } - case s_body_what: + case s_body_pause: { auto const what = call_on_body_what(ec); if(ec)