diff --git a/CHANGELOG.md b/CHANGELOG.md
index 733d8ce9..69ff9bfb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@ Version 54:
* consuming_buffers members and coverage
* basic_fields members and coverage
* Add string_param
+* Retain ownership when reading using a message
API Changes:
diff --git a/include/beast/http/impl/read.ipp b/include/beast/http/impl/read.ipp
index e99aa52d..473afc5f 100644
--- a/include/beast/http/impl/read.ipp
+++ b/include/beast/http/impl/read.ipp
@@ -325,6 +325,7 @@ class read_msg_op
: s(s_)
, b(b_)
, m(m_)
+ , p(std::move(m))
{
p.eager(true);
}
@@ -725,7 +726,7 @@ read(
"Body requirements not met");
static_assert(is_body_writer
::value,
"BodyWriter requirements not met");
- parser p;
+ parser p{std::move(msg)};
p.eager(true);
read(stream, buffer, p.base(), ec);
if(ec)
diff --git a/include/beast/http/read.hpp b/include/beast/http/read.hpp
index 6b2902e2..e79f19f8 100644
--- a/include/beast/http/read.hpp
+++ b/include/beast/http/read.hpp
@@ -604,8 +604,8 @@ async_read(
dynamic buffer's input sequence will be given to the parser
first.
- @param msg An object used to store the message. Any contents will
- be overwritten. The type must support copy or move assignment.
+ @param msg An object to be overwritten with the message contents.
+ The type must be @b MoveAssignable and @b MoveConstructible.
@throws system_error Thrown on failure.
*/
@@ -654,8 +654,8 @@ read(
dynamic buffer's input sequence will be given to the parser
first.
- @param msg An object used to store the message. Any contents will
- be overwritten. The type must support copy or move assignment.
+ @param msg An object to be overwritten with the message contents.
+ The type must be @b MoveAssignable and @b MoveConstructible.
@param ec Set to the error, if any occurred.
*/
@@ -709,8 +709,8 @@ read(
dynamic buffer's input sequence will be given to the parser
first.
- @param msg An object used to store the message. Any contents will
- be overwritten. The type must support copy or move assignment.
+ @param msg An object to be overwritten with the message contents.
+ The type must be @b MoveAssignable and @b MoveConstructible.
The object must remain valid at least until the
handler is called; ownership is not transferred.