forked from boostorg/beast
Add message::need_eof
This commit is contained in:
1 parent
5c14ab9f7c
commit
1754d5427d
4 files changed
+163
No files matched your search
@@ -343,6 +343,22 @@ payload_size() const
|
||||
return payload_size(detail::is_body_sized<Body>{});
|
||||
}
|
||||
|
||||
template<bool isRequest, class Body, class Fields>
|
||||
bool
|
||||
message<isRequest, Body, Fields>::
|
||||
need_eof(std::false_type) const
|
||||
{
|
||||
// VFALCO Do we need a way to let the caller say "the body is intentionally skipped"?
|
||||
if( this->result() == status::no_content ||
|
||||
this->result() == status::not_modified ||
|
||||
to_status_class(this->result()) ==
|
||||
status_class::informational ||
|
||||
has_content_length() ||
|
||||
chunked())
|
||||
return ! keep_alive();
|
||||
return true;
|
||||
}
|
||||
|
||||
template<bool isRequest, class Body, class Fields>
|
||||
void
|
||||
message<isRequest, Body, Fields>::
|
||||
|
||||
@@ -780,6 +780,34 @@ struct message
|
||||
this->set_keep_alive_impl(this->version(), value);
|
||||
}
|
||||
|
||||
/** Returns `true` if the message semantics require an end of file.
|
||||
|
||||
For HTTP requests, this function returns the logical
|
||||
NOT of a call to @ref keep_alive.
|
||||
|
||||
For HTTP responses, this function returns the logical NOT
|
||||
of a call to @ref keep_alive if any of the following are true:
|
||||
|
||||
@li @ref has_content_length would return `true`
|
||||
|
||||
@li @ref chunked would return `true`
|
||||
|
||||
@li @ref result returns @ref status::no_content
|
||||
|
||||
@li @ref result returns @ref status::not_modified
|
||||
|
||||
@li @ref result returns any informational status class (100 to 199)
|
||||
|
||||
Otherwise, the function returns `true`.
|
||||
|
||||
@see https://tools.ietf.org/html/rfc7230#section-3.3
|
||||
*/
|
||||
bool
|
||||
need_eof() const
|
||||
{
|
||||
return need_eof(typename header_type::is_request{});
|
||||
}
|
||||
|
||||
/** Returns the payload size of the body in octets if possible.
|
||||
|
||||
This function invokes the @b Body algorithm to measure
|
||||
@@ -878,6 +906,15 @@ private:
|
||||
boost::ignore_unused(fields_args);
|
||||
}
|
||||
|
||||
bool
|
||||
need_eof(std::true_type) const
|
||||
{
|
||||
return ! keep_alive();
|
||||
}
|
||||
|
||||
bool
|
||||
need_eof(std::false_type) const;
|
||||
|
||||
boost::optional<std::uint64_t>
|
||||
payload_size(std::true_type) const
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user