mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 20:37:31 +02:00
Remove deprecated Body reader and writer ctor signatures
This commit is contained in:
@ -7,6 +7,7 @@ Version 170:
|
||||
* Add test::stream to experimental
|
||||
* Use a shared string for example HTTP server doc roots
|
||||
* Remove deprecated serializer::reader_impl()
|
||||
* Remove deprecated Body reader and writer ctor signatures
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -194,22 +194,6 @@ struct is_fields_helper : T
|
||||
t10::value && t11::value && t12::value>;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
using has_deprecated_body_writer =
|
||||
std::integral_constant<bool,
|
||||
std::is_constructible<typename T::writer,
|
||||
message<true, T, detail::fields_model>&>::value &&
|
||||
std::is_constructible<typename T::writer,
|
||||
message<false, T, detail::fields_model>&>::value>;
|
||||
|
||||
template<class T>
|
||||
using has_deprecated_body_reader =
|
||||
std::integral_constant<bool,
|
||||
std::is_constructible<typename T::reader,
|
||||
message<true, T, detail::fields_model>&>::value &&
|
||||
std::is_constructible<typename T::reader,
|
||||
message<false, T, detail::fields_model>&>::value>;
|
||||
|
||||
} // detail
|
||||
} // http
|
||||
} // beast
|
||||
|
@ -20,25 +20,6 @@ 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())
|
||||
{
|
||||
}
|
||||
@ -47,37 +28,8 @@ 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),
|
||||
: m_(
|
||||
std::forward<Arg1>(arg1),
|
||||
std::forward<ArgN>(argn)...)
|
||||
, rd_(m_.base(), m_.body())
|
||||
{
|
||||
@ -90,36 +42,6 @@ parser<isRequest, Body, Allocator>::
|
||||
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_)
|
||||
{
|
||||
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())
|
||||
|
@ -57,34 +57,12 @@ do_visit(error_code& ec, Visit& visit)
|
||||
template<
|
||||
bool isRequest, class Body, class Fields>
|
||||
serializer<isRequest, Body, Fields>::
|
||||
serializer(value_type& m, std::true_type)
|
||||
: m_(m)
|
||||
, wr_(m_)
|
||||
{
|
||||
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
|
||||
// Deprecated BodyWriter Concept (v1.66)
|
||||
static_assert(sizeof(Body) == 0,
|
||||
BOOST_BEAST_DEPRECATION_STRING);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<
|
||||
bool isRequest, class Body, class Fields>
|
||||
serializer<isRequest, Body, Fields>::
|
||||
serializer(value_type& m, std::false_type)
|
||||
serializer(value_type& m)
|
||||
: m_(m)
|
||||
, wr_(m_.base(), m_.body())
|
||||
{
|
||||
}
|
||||
|
||||
template<
|
||||
bool isRequest, class Body, class Fields>
|
||||
serializer<isRequest, Body, Fields>::
|
||||
serializer(value_type& m)
|
||||
: serializer(m, detail::has_deprecated_body_writer<Body>{})
|
||||
{
|
||||
}
|
||||
|
||||
template<
|
||||
bool isRequest, class Body, class Fields>
|
||||
template<class Visit>
|
||||
|
@ -72,17 +72,12 @@ public:
|
||||
using value_type = implementation_defined;
|
||||
#else
|
||||
using value_type = typename std::conditional<
|
||||
(std::is_constructible<typename Body::writer,
|
||||
std::is_constructible<typename Body::writer,
|
||||
header<isRequest, Fields>&,
|
||||
typename Body::value_type&>::value &&
|
||||
! std::is_constructible<typename Body::writer,
|
||||
header<isRequest, Fields> const&,
|
||||
typename Body::value_type const&>::value) ||
|
||||
// Deprecated BodyWriter Concept (v1.66)
|
||||
(std::is_constructible<typename Body::writer,
|
||||
message<isRequest, Body, Fields>&>::value &&
|
||||
! std::is_constructible<typename Body::writer,
|
||||
message<isRequest, Body, Fields> const&>::value),
|
||||
typename Body::value_type const&>::value,
|
||||
message<isRequest, Body, Fields>,
|
||||
message<isRequest, Body, Fields> const>::type;
|
||||
#endif
|
||||
@ -194,8 +189,6 @@ private:
|
||||
bool header_done_ = false;
|
||||
bool more_;
|
||||
|
||||
serializer(value_type& msg, std::true_type);
|
||||
serializer(value_type& msg, std::false_type);
|
||||
public:
|
||||
/// Constructor
|
||||
serializer(serializer&&) = default;
|
||||
|
@ -95,12 +95,7 @@ struct is_body_writer<T, beast::detail::void_t<
|
||||
typename T::value_type&>::value &&
|
||||
std::is_constructible<typename T::writer,
|
||||
header<false, detail::fields_model>&,
|
||||
typename T::value_type&>::value) ||
|
||||
// Deprecated BodyWriter Concept (v1.66)
|
||||
(std::is_constructible<typename T::writer,
|
||||
message<true, T, detail::fields_model>&>::value &&
|
||||
std::is_constructible<typename T::writer,
|
||||
message<false, T, detail::fields_model>&>::value)
|
||||
typename T::value_type&>::value)
|
||||
)
|
||||
> {};
|
||||
#endif
|
||||
@ -149,12 +144,7 @@ struct is_body_reader<T, beast::detail::void_t<decltype(
|
||||
typename T::value_type&>::value &&
|
||||
std::is_constructible<typename T::reader,
|
||||
header<false,detail::fields_model>&,
|
||||
typename T::value_type&>::value) ||
|
||||
// Deprecated BodyReader Concept (v1.66)
|
||||
(std::is_constructible<typename T::reader,
|
||||
message<true, T, detail::fields_model>&>::value &&
|
||||
std::is_constructible<typename T::reader,
|
||||
message<false, T, detail::fields_model>&>::value)
|
||||
typename T::value_type&>::value)
|
||||
>
|
||||
{
|
||||
};
|
||||
|
@ -36,42 +36,6 @@ 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)
|
||||
@ -379,12 +343,6 @@ public:
|
||||
BEAST_EXPECT(std::distance(m1.begin(), m1.end()) == 0);
|
||||
}
|
||||
|
||||
void testBodyReaderCtor()
|
||||
{
|
||||
request_parser<deprecated_body> p;
|
||||
boost::ignore_unused(p);
|
||||
}
|
||||
|
||||
void
|
||||
run() override
|
||||
{
|
||||
@ -393,7 +351,6 @@ public:
|
||||
testNeedMore<multi_buffer>();
|
||||
testGotSome();
|
||||
testIssue818();
|
||||
testBodyReaderCtor();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -20,40 +20,6 @@ namespace http {
|
||||
class serializer_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
struct deprecated_body
|
||||
{
|
||||
using value_type = std::string;
|
||||
|
||||
class writer
|
||||
{
|
||||
public:
|
||||
using const_buffers_type =
|
||||
boost::asio::const_buffer;
|
||||
|
||||
value_type const& body_;
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
explicit
|
||||
writer(message<isRequest, deprecated_body, Fields> const& m):
|
||||
body_{m.body()}
|
||||
{
|
||||
}
|
||||
|
||||
void init(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
|
||||
boost::optional<std::pair<const_buffers_type, bool>>
|
||||
get(error_code& ec)
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
return {{const_buffers_type{
|
||||
body_.data(), body_.size()}, false}};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
struct const_body
|
||||
{
|
||||
struct value_type{};
|
||||
@ -149,20 +115,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void testBodyWriterCtor()
|
||||
{
|
||||
response<deprecated_body> res;
|
||||
request<deprecated_body> req;
|
||||
serializer<false, deprecated_body> sr1{res};
|
||||
serializer<true, deprecated_body> sr2{req};
|
||||
boost::ignore_unused(sr1, sr2);
|
||||
}
|
||||
|
||||
void
|
||||
run() override
|
||||
{
|
||||
testWriteLimit();
|
||||
testBodyWriterCtor();
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user