forked from boostorg/beast
Add has_content_length_impl to Fields (API Change):
* The function has_content_length_impl is added to the requirements of Fields. Actions Required: * Implement has_content_length_impl for user-defined Fields
This commit is contained in:
1 parent
feb525f829
commit
6225c5bd2f
8 files changed
+69
-11
No files matched your search
@@ -61,6 +61,7 @@ protected:
|
||||
string_view get_reason_impl() const;
|
||||
bool get_chunked_impl() const;
|
||||
bool get_keep_alive_impl(unsigned) const;
|
||||
bool has_content_length_impl() const;
|
||||
void set_method_impl(string_view);
|
||||
void set_target_impl(string_view);
|
||||
void set_reason_impl(string_view);
|
||||
@@ -134,54 +135,61 @@ struct is_fields_helper : T
|
||||
|
||||
template<class U = is_fields_helper>
|
||||
static auto f6(int) -> decltype(
|
||||
void(std::declval<U&>().set_method_impl(std::declval<string_view>())),
|
||||
std::declval<bool&>() = std::declval<U const&>().has_content_length_impl(),
|
||||
std::true_type());
|
||||
static auto f6(...) -> std::false_type;
|
||||
using t6 = decltype(f6(0));
|
||||
|
||||
template<class U = is_fields_helper>
|
||||
static auto f7(int) -> decltype(
|
||||
void(std::declval<U&>().set_target_impl(std::declval<string_view>())),
|
||||
void(std::declval<U&>().set_method_impl(std::declval<string_view>())),
|
||||
std::true_type());
|
||||
static auto f7(...) -> std::false_type;
|
||||
using t7 = decltype(f7(0));
|
||||
|
||||
template<class U = is_fields_helper>
|
||||
static auto f8(int) -> decltype(
|
||||
void(std::declval<U&>().set_reason_impl(std::declval<string_view>())),
|
||||
void(std::declval<U&>().set_target_impl(std::declval<string_view>())),
|
||||
std::true_type());
|
||||
static auto f8(...) -> std::false_type;
|
||||
using t8 = decltype(f8(0));
|
||||
|
||||
template<class U = is_fields_helper>
|
||||
static auto f9(int) -> decltype(
|
||||
void(std::declval<U&>().set_chunked_impl(std::declval<bool>())),
|
||||
void(std::declval<U&>().set_reason_impl(std::declval<string_view>())),
|
||||
std::true_type());
|
||||
static auto f9(...) -> std::false_type;
|
||||
using t9 = decltype(f9(0));
|
||||
|
||||
template<class U = is_fields_helper>
|
||||
static auto f10(int) -> decltype(
|
||||
void(std::declval<U&>().set_content_length_impl(
|
||||
std::declval<boost::optional<std::uint64_t>>())),
|
||||
void(std::declval<U&>().set_chunked_impl(std::declval<bool>())),
|
||||
std::true_type());
|
||||
static auto f10(...) -> std::false_type;
|
||||
using t10 = decltype(f10(0));
|
||||
|
||||
template<class U = is_fields_helper>
|
||||
static auto f11(int) -> decltype(
|
||||
void(std::declval<U&>().set_content_length_impl(
|
||||
std::declval<boost::optional<std::uint64_t>>())),
|
||||
std::true_type());
|
||||
static auto f11(...) -> std::false_type;
|
||||
using t11 = decltype(f11(0));
|
||||
|
||||
template<class U = is_fields_helper>
|
||||
static auto f12(int) -> decltype(
|
||||
void(std::declval<U&>().set_keep_alive_impl(
|
||||
std::declval<unsigned>(),
|
||||
std::declval<bool>())),
|
||||
std::true_type());
|
||||
static auto f11(...) -> std::false_type;
|
||||
using t11 = decltype(f11(0));
|
||||
static auto f12(...) -> std::false_type;
|
||||
using t12 = decltype(f12(0));
|
||||
|
||||
using type = std::integral_constant<bool,
|
||||
t1::value && t2::value && t3::value &&
|
||||
t4::value && t5::value && t6::value &&
|
||||
t7::value && t8::value && t9::value &&
|
||||
t10::value && t11::value>;
|
||||
t10::value && t11::value && t12::value>;
|
||||
};
|
||||
|
||||
} // detail
|
||||
|
||||
@@ -634,6 +634,11 @@ protected:
|
||||
bool
|
||||
get_keep_alive_impl(unsigned version) const;
|
||||
|
||||
/** Returns `true` if the Content-Length field is present.
|
||||
*/
|
||||
bool
|
||||
has_content_length_impl() const;
|
||||
|
||||
/** Set or clear the method string.
|
||||
|
||||
@note Only called for requests.
|
||||
|
||||
@@ -938,6 +938,14 @@ get_keep_alive_impl(unsigned version) const
|
||||
it->value()}.exists("close");
|
||||
}
|
||||
|
||||
template<class Allocator>
|
||||
bool
|
||||
basic_fields<Allocator>::
|
||||
has_content_length_impl() const
|
||||
{
|
||||
return count(field::content_length) > 0;
|
||||
}
|
||||
|
||||
template<class Allocator>
|
||||
inline
|
||||
void
|
||||
|
||||
@@ -723,6 +723,18 @@ struct message
|
||||
void
|
||||
chunked(bool value);
|
||||
|
||||
/** Returns `true` if the Content-Length field is present.
|
||||
|
||||
This function inspects the fields and returns `true` if
|
||||
the Content-Length field is present. The properties of the
|
||||
body are not checked, this only looks for the field.
|
||||
*/
|
||||
bool
|
||||
has_content_length() const
|
||||
{
|
||||
return this->has_content_length_impl();
|
||||
}
|
||||
|
||||
/** Set or clear the Content-Length field
|
||||
|
||||
This function adjusts the Content-Length field as follows:
|
||||
|
||||
Reference in new issue
Block a user