From f44380159ab4f208f46bdeae9d174fc7e8d3c73b Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sun, 11 Jun 2017 11:49:04 -0700 Subject: [PATCH] Retain ownership when reading using a message fix #469 --- CHANGELOG.md | 1 + include/beast/http/impl/read.ipp | 3 ++- include/beast/http/read.hpp | 12 ++++++------ 3 files changed, 9 insertions(+), 7 deletions(-) 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.