mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 04:47:29 +02:00
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:
16
CHANGELOG.md
16
CHANGELOG.md
@ -1,3 +1,19 @@
|
||||
Version 59:
|
||||
|
||||
* Integrated Beast INTERFACE (cmake)
|
||||
|
||||
API Changes:
|
||||
|
||||
* Change Body::size signature (API Change):
|
||||
|
||||
Actions Required:
|
||||
|
||||
* For any user-defined models of Body, change the function signature
|
||||
to accept `value_type const&` and modify the function definition
|
||||
accordingly.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Version 58:
|
||||
|
||||
* Fix unaligned reads in utf8-checker
|
||||
|
@ -66,6 +66,11 @@ struct Body
|
||||
class reader;
|
||||
|
||||
class writer;
|
||||
|
||||
// Optional member
|
||||
static
|
||||
std::uint64_t
|
||||
size(value_type const&);
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -48,10 +48,10 @@ In this table:
|
||||
the message body for serialization.
|
||||
]
|
||||
][
|
||||
[`X::size(m)`]
|
||||
[`X::size(X::value_type const& v)`]
|
||||
[`std::uint64_t`]
|
||||
[
|
||||
If present, returns the serialized size of `m.body` not including
|
||||
If present, returns the serialized size of `v` not including
|
||||
any chunked transfer encoding. When this function is provided,
|
||||
[link beast.ref.beast__http__message.prepare `message::prepare`]
|
||||
will automatically set the content length field based on the
|
||||
@ -80,10 +80,9 @@ struct body
|
||||
class writer;
|
||||
|
||||
/// Returns the body's payload size
|
||||
template<bool isRequest, class Fields>
|
||||
static
|
||||
std::uint64_t
|
||||
size(message<isRequest, empty_body, Fields> const& m);
|
||||
size(value_type const& v);
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -48,10 +48,9 @@ struct file_body
|
||||
|
||||
@return The size of the file in bytes.
|
||||
*/
|
||||
template<bool isRequest, class Fields>
|
||||
static
|
||||
std::uint64_t
|
||||
size(message<isRequest, file_body, Fields> const& m);
|
||||
size(value_type const& v);
|
||||
|
||||
/** Algorithm for retrieving buffers when serializing.
|
||||
|
||||
@ -72,12 +71,11 @@ struct file_body
|
||||
|
||||
//[example_http_file_body_2
|
||||
|
||||
template<bool isRequest, class Fields>
|
||||
std::uint64_t
|
||||
file_body::
|
||||
size(message<isRequest, file_body, Fields> const& m)
|
||||
size(value_type const& v)
|
||||
{
|
||||
return boost::filesystem::file_size(m.body);
|
||||
return boost::filesystem::file_size(v);
|
||||
}
|
||||
|
||||
//]
|
||||
|
@ -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