forked from boostorg/beast
Change Body::size signature (API Change):
fix #497 This changes the function signature to accept the `value_type` instead of the entire message. Actions Required: * For any user-defined models of Body, change the function signature to accept `value_type const&` and modify the function definition accordingly.
This commit is contained in:
@@ -62,17 +62,17 @@ struct has_value_type<T, beast::detail::void_t<
|
||||
/** Determine if a @b Body type has a size
|
||||
|
||||
This metafunction is equivalent to `std::true_type` if
|
||||
Body contains a static member function called `content_lengeth`.
|
||||
Body contains a static member function called `size`.
|
||||
*/
|
||||
template<class T, class M, class = void>
|
||||
template<class T, class = void>
|
||||
struct is_body_sized : std::false_type {};
|
||||
|
||||
template<class T, class M>
|
||||
struct is_body_sized<T, M, beast::detail::void_t<
|
||||
template<class T>
|
||||
struct is_body_sized<T, beast::detail::void_t<
|
||||
typename T::value_type,
|
||||
decltype(
|
||||
std::declval<std::uint64_t&>() =
|
||||
T::size(std::declval<M const&>()),
|
||||
T::size(std::declval<typename T::value_type const&>()),
|
||||
(void)0)>> : std::true_type {};
|
||||
|
||||
} // detail
|
||||
|
||||
@@ -29,13 +29,11 @@ struct basic_dynamic_body
|
||||
using value_type = DynamicBuffer;
|
||||
|
||||
/// Returns the content length of this body in a message.
|
||||
template<bool isRequest, class Fields>
|
||||
static
|
||||
std::uint64_t
|
||||
size(message<isRequest,
|
||||
basic_dynamic_body, Fields> const& m)
|
||||
size(value_type const& v)
|
||||
{
|
||||
return m.body.size();
|
||||
return v.size();
|
||||
}
|
||||
|
||||
#if BEAST_DOXYGEN
|
||||
|
||||
@@ -36,10 +36,9 @@ struct empty_body
|
||||
};
|
||||
|
||||
/// Returns the content length of the body in a message.
|
||||
template<bool isRequest, class Fields>
|
||||
static
|
||||
std::uint64_t
|
||||
size(message<isRequest, empty_body, Fields> const& m)
|
||||
size(empty_body)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -285,8 +285,7 @@ size() const
|
||||
static_assert(is_body_reader<Body>::value,
|
||||
"BodyReader requirements not met");
|
||||
|
||||
return size(detail::is_body_sized<
|
||||
Body, decltype(*this)>{});
|
||||
return size(detail::is_body_sized<Body>{});
|
||||
}
|
||||
|
||||
template<bool isRequest, class Body, class Fields>
|
||||
|
||||
@@ -558,7 +558,7 @@ private:
|
||||
boost::optional<std::uint64_t>
|
||||
size(std::true_type) const
|
||||
{
|
||||
return Body::size(*this);
|
||||
return Body::size(body);
|
||||
}
|
||||
|
||||
boost::optional<std::uint64_t>
|
||||
|
||||
@@ -31,13 +31,11 @@ struct string_body
|
||||
using value_type = std::string;
|
||||
|
||||
/// Returns the content length of the body in a message.
|
||||
template<bool isRequest, class Fields>
|
||||
static
|
||||
std::uint64_t
|
||||
size(
|
||||
message<isRequest, string_body, Fields> const& m)
|
||||
size(value_type const& v)
|
||||
{
|
||||
return m.body.size();
|
||||
return v.size();
|
||||
}
|
||||
|
||||
#if BEAST_DOXYGEN
|
||||
|
||||
@@ -32,13 +32,11 @@ struct string_view_body
|
||||
using value_type = string_view;
|
||||
|
||||
/// Returns the content length of this body in a message.
|
||||
template<bool isRequest, class Fields>
|
||||
static
|
||||
std::uint64_t
|
||||
size(message<isRequest,
|
||||
string_view_body, Fields> const& m)
|
||||
size(value_type const& v)
|
||||
{
|
||||
return m.body.size();
|
||||
return v.size();
|
||||
}
|
||||
|
||||
#if BEAST_DOXYGEN
|
||||
|
||||
Reference in New Issue
Block a user