forked from boostorg/beast
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:
1 parent
d796319476
commit
b76ab4450a
24 files changed
+358
-107
No files matched your search
@@ -20,26 +20,87 @@ namespace http {
|
||||
template<bool isRequest, class Body, class Allocator>
|
||||
parser<isRequest, Body, Allocator>::
|
||||
parser()
|
||||
: parser{detail::has_deprecated_body_reader<Body>{}}
|
||||
{
|
||||
}
|
||||
|
||||
template<bool isRequest, class Body, class Allocator>
|
||||
parser<isRequest, Body, Allocator>::
|
||||
parser(std::true_type)
|
||||
: rd_(m_)
|
||||
{
|
||||
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
|
||||
// Deprecated BodyReader Concept (v1.66)
|
||||
static_assert(sizeof(Body) == 0,
|
||||
BOOST_BEAST_DEPRECATION_STRING);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<bool isRequest, class Body, class Allocator>
|
||||
parser<isRequest, Body, Allocator>::
|
||||
parser(std::false_type)
|
||||
: rd_(m_.base(), m_.body())
|
||||
{
|
||||
}
|
||||
|
||||
template<bool isRequest, class Body, class Allocator>
|
||||
template<class Arg1, class... ArgN, class>
|
||||
parser<isRequest, Body, Allocator>::
|
||||
parser(Arg1&& arg1, ArgN&&... argn)
|
||||
: parser(std::forward<Arg1>(arg1),
|
||||
detail::has_deprecated_body_reader<Body>{},
|
||||
std::forward<ArgN>(argn)...)
|
||||
{
|
||||
}
|
||||
|
||||
// VFALCO arg1 comes before `true_type` to make
|
||||
// the signature unambiguous.
|
||||
template<bool isRequest, class Body, class Allocator>
|
||||
template<class Arg1, class... ArgN, class>
|
||||
parser<isRequest, Body, Allocator>::
|
||||
parser(Arg1&& arg1, std::true_type, ArgN&&... argn)
|
||||
: m_(std::forward<Arg1>(arg1),
|
||||
std::forward<ArgN>(argn)...)
|
||||
, rd_(m_)
|
||||
{
|
||||
m_.clear();
|
||||
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
|
||||
/* Deprecated BodyWriter Concept (v1.66) */
|
||||
static_assert(sizeof(Body) == 0,
|
||||
BOOST_BEAST_DEPRECATION_STRING);
|
||||
#endif // BOOST_BEAST_ALLOW_DEPRECATED
|
||||
}
|
||||
|
||||
// VFALCO arg1 comes before `false_type` to make
|
||||
// the signature unambiguous.
|
||||
template<bool isRequest, class Body, class Allocator>
|
||||
template<class Arg1, class... ArgN, class>
|
||||
parser<isRequest, Body, Allocator>::
|
||||
parser(Arg1&& arg1, std::false_type, ArgN&&... argn)
|
||||
: m_(std::forward<Arg1>(arg1),
|
||||
std::forward<ArgN>(argn)...)
|
||||
, rd_(m_.base(), m_.body())
|
||||
{
|
||||
m_.clear();
|
||||
}
|
||||
|
||||
template<bool isRequest, class Body, class Allocator>
|
||||
template<class OtherBody, class... Args, class>
|
||||
parser<isRequest, Body, Allocator>::
|
||||
parser(parser<isRequest, OtherBody, Allocator>&& other,
|
||||
Args&&... args)
|
||||
parser(
|
||||
parser<isRequest, OtherBody, Allocator>&& other,
|
||||
Args&&... args)
|
||||
: parser(detail::has_deprecated_body_reader<Body>{},
|
||||
std::move(other), std::forward<Args>(args)...)
|
||||
{
|
||||
}
|
||||
|
||||
template<bool isRequest, class Body, class Allocator>
|
||||
template<class OtherBody, class... Args, class>
|
||||
parser<isRequest, Body, Allocator>::
|
||||
parser(std::true_type,
|
||||
parser<isRequest, OtherBody, Allocator>&& other,
|
||||
Args&&... args)
|
||||
: base_type(std::move(other))
|
||||
, m_(other.release(), std::forward<Args>(args)...)
|
||||
, rd_(m_)
|
||||
@@ -47,6 +108,25 @@ parser(parser<isRequest, OtherBody, Allocator>&& other,
|
||||
if(other.rd_inited_)
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument{
|
||||
"moved-from parser has a body"});
|
||||
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
|
||||
// Deprecated BodyReader Concept (v1.66)
|
||||
static_assert(sizeof(Body) == 0,
|
||||
BOOST_BEAST_DEPRECATION_STRING);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<bool isRequest, class Body, class Allocator>
|
||||
template<class OtherBody, class... Args, class>
|
||||
parser<isRequest, Body, Allocator>::
|
||||
parser(std::false_type, parser<isRequest, OtherBody, Allocator>&& other,
|
||||
Args&&... args)
|
||||
: base_type(std::move(other))
|
||||
, m_(other.release(), std::forward<Args>(args)...)
|
||||
, rd_(m_.base(), m_.body())
|
||||
{
|
||||
if(other.rd_inited_)
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument{
|
||||
"moved-from parser has a body"});
|
||||
}
|
||||
|
||||
} // http
|
||||
|
||||
Reference in new issue
Block a user