New BodyReader and BodyWriter constructors (API Change):

fix #884

* BodyReader and BodyWriter constructors now require the header and
  body elements to be passed as distinct header and value_type objects.

This enables the composition of body types, for example:

    http::response<compressed_body<http::string_body>> res;

* The previous single-argument constructors are deprecated and will be
  removed in a subsequent version.

Actions Required:

* Change user-defined instances of BodyReader or BodyWriter constructor
  signatures to the two-argument form.

OR

* Define the macro BOOST_BEAST_ALLOW_DEPRECATED in the project (which
  will accept both the new and the deprecated signatures).
This commit is contained in:
Damian Jarek
2017-12-15 09:27:39 -08:00
committed by Vinnie Falco
parent d796319476
commit b76ab4450a
24 changed files with 358 additions and 107 deletions
+43
View File
@@ -36,6 +36,42 @@ public:
using parser_type =
parser<isRequest, string_body>;
struct deprecated_body
{
using value_type = std::string;
class reader
{
public:
template<bool isRequest, class Fields>
explicit
reader(message<isRequest, deprecated_body, Fields>&)
{
}
void
init(boost::optional<std::uint64_t> const&, error_code& ec)
{
ec = {};
}
template<class ConstBufferSequence>
std::size_t
put(ConstBufferSequence const& buffers, error_code& ec)
{
ec = {};
return boost::asio::buffer_size(buffers);
}
void
finish(error_code& ec)
{
ec = {};
}
};
};
static
boost::asio::const_buffer
buf(string_view s)
@@ -343,6 +379,12 @@ public:
BEAST_EXPECT(std::distance(m1.begin(), m1.end()) == 0);
}
void testBodyReaderCtor()
{
request_parser<deprecated_body> p;
boost::ignore_unused(p);
}
void
run() override
{
@@ -351,6 +393,7 @@ public:
testNeedMore<multi_buffer>();
testGotSome();
testIssue818();
testBodyReaderCtor();
}
};