mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 12:57: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
|
* Add test::stream to experimental
|
||||||
* Use a shared string for example HTTP server doc roots
|
* Use a shared string for example HTTP server doc roots
|
||||||
* Remove deprecated serializer::reader_impl()
|
* 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>;
|
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
|
} // detail
|
||||||
} // http
|
} // http
|
||||||
} // beast
|
} // beast
|
||||||
|
@ -20,25 +20,6 @@ namespace http {
|
|||||||
template<bool isRequest, class Body, class Allocator>
|
template<bool isRequest, class Body, class Allocator>
|
||||||
parser<isRequest, Body, Allocator>::
|
parser<isRequest, Body, Allocator>::
|
||||||
parser()
|
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())
|
: rd_(m_.base(), m_.body())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -47,37 +28,8 @@ template<bool isRequest, class Body, class Allocator>
|
|||||||
template<class Arg1, class... ArgN, class>
|
template<class Arg1, class... ArgN, class>
|
||||||
parser<isRequest, Body, Allocator>::
|
parser<isRequest, Body, Allocator>::
|
||||||
parser(Arg1&& arg1, ArgN&&... argn)
|
parser(Arg1&& arg1, ArgN&&... argn)
|
||||||
: parser(std::forward<Arg1>(arg1),
|
: m_(
|
||||||
detail::has_deprecated_body_reader<Body>{},
|
std::forward<Arg1>(arg1),
|
||||||
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)...)
|
std::forward<ArgN>(argn)...)
|
||||||
, rd_(m_.base(), m_.body())
|
, rd_(m_.base(), m_.body())
|
||||||
{
|
{
|
||||||
@ -90,36 +42,6 @@ parser<isRequest, Body, Allocator>::
|
|||||||
parser(
|
parser(
|
||||||
parser<isRequest, OtherBody, Allocator>&& other,
|
parser<isRequest, OtherBody, Allocator>&& other,
|
||||||
Args&&... args)
|
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))
|
: base_type(std::move(other))
|
||||||
, m_(other.release(), std::forward<Args>(args)...)
|
, m_(other.release(), std::forward<Args>(args)...)
|
||||||
, rd_(m_.base(), m_.body())
|
, rd_(m_.base(), m_.body())
|
||||||
|
@ -57,34 +57,12 @@ do_visit(error_code& ec, Visit& visit)
|
|||||||
template<
|
template<
|
||||||
bool isRequest, class Body, class Fields>
|
bool isRequest, class Body, class Fields>
|
||||||
serializer<isRequest, Body, Fields>::
|
serializer<isRequest, Body, Fields>::
|
||||||
serializer(value_type& m, std::true_type)
|
serializer(value_type& m)
|
||||||
: 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)
|
|
||||||
: m_(m)
|
: m_(m)
|
||||||
, wr_(m_.base(), m_.body())
|
, 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<
|
template<
|
||||||
bool isRequest, class Body, class Fields>
|
bool isRequest, class Body, class Fields>
|
||||||
template<class Visit>
|
template<class Visit>
|
||||||
|
@ -72,17 +72,12 @@ public:
|
|||||||
using value_type = implementation_defined;
|
using value_type = implementation_defined;
|
||||||
#else
|
#else
|
||||||
using value_type = typename std::conditional<
|
using value_type = typename std::conditional<
|
||||||
(std::is_constructible<typename Body::writer,
|
std::is_constructible<typename Body::writer,
|
||||||
header<isRequest, Fields>&,
|
header<isRequest, Fields>&,
|
||||||
typename Body::value_type&>::value &&
|
typename Body::value_type&>::value &&
|
||||||
! std::is_constructible<typename Body::writer,
|
! std::is_constructible<typename Body::writer,
|
||||||
header<isRequest, Fields> const&,
|
header<isRequest, Fields> const&,
|
||||||
typename Body::value_type const&>::value) ||
|
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),
|
|
||||||
message<isRequest, Body, Fields>,
|
message<isRequest, Body, Fields>,
|
||||||
message<isRequest, Body, Fields> const>::type;
|
message<isRequest, Body, Fields> const>::type;
|
||||||
#endif
|
#endif
|
||||||
@ -194,8 +189,6 @@ private:
|
|||||||
bool header_done_ = false;
|
bool header_done_ = false;
|
||||||
bool more_;
|
bool more_;
|
||||||
|
|
||||||
serializer(value_type& msg, std::true_type);
|
|
||||||
serializer(value_type& msg, std::false_type);
|
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
serializer(serializer&&) = default;
|
serializer(serializer&&) = default;
|
||||||
|
@ -95,12 +95,7 @@ struct is_body_writer<T, beast::detail::void_t<
|
|||||||
typename T::value_type&>::value &&
|
typename T::value_type&>::value &&
|
||||||
std::is_constructible<typename T::writer,
|
std::is_constructible<typename T::writer,
|
||||||
header<false, detail::fields_model>&,
|
header<false, detail::fields_model>&,
|
||||||
typename T::value_type&>::value) ||
|
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)
|
|
||||||
)
|
)
|
||||||
> {};
|
> {};
|
||||||
#endif
|
#endif
|
||||||
@ -149,12 +144,7 @@ struct is_body_reader<T, beast::detail::void_t<decltype(
|
|||||||
typename T::value_type&>::value &&
|
typename T::value_type&>::value &&
|
||||||
std::is_constructible<typename T::reader,
|
std::is_constructible<typename T::reader,
|
||||||
header<false,detail::fields_model>&,
|
header<false,detail::fields_model>&,
|
||||||
typename T::value_type&>::value) ||
|
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)
|
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
@ -36,42 +36,6 @@ public:
|
|||||||
using parser_type =
|
using parser_type =
|
||||||
parser<isRequest, string_body>;
|
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
|
static
|
||||||
boost::asio::const_buffer
|
boost::asio::const_buffer
|
||||||
buf(string_view s)
|
buf(string_view s)
|
||||||
@ -379,12 +343,6 @@ public:
|
|||||||
BEAST_EXPECT(std::distance(m1.begin(), m1.end()) == 0);
|
BEAST_EXPECT(std::distance(m1.begin(), m1.end()) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testBodyReaderCtor()
|
|
||||||
{
|
|
||||||
request_parser<deprecated_body> p;
|
|
||||||
boost::ignore_unused(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
run() override
|
run() override
|
||||||
{
|
{
|
||||||
@ -393,7 +351,6 @@ public:
|
|||||||
testNeedMore<multi_buffer>();
|
testNeedMore<multi_buffer>();
|
||||||
testGotSome();
|
testGotSome();
|
||||||
testIssue818();
|
testIssue818();
|
||||||
testBodyReaderCtor();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,40 +20,6 @@ namespace http {
|
|||||||
class serializer_test : public beast::unit_test::suite
|
class serializer_test : public beast::unit_test::suite
|
||||||
{
|
{
|
||||||
public:
|
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 const_body
|
||||||
{
|
{
|
||||||
struct value_type{};
|
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
|
void
|
||||||
run() override
|
run() override
|
||||||
{
|
{
|
||||||
testWriteLimit();
|
testWriteLimit();
|
||||||
testBodyWriterCtor();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user