class response_builder
#
-
class response_builder#
A type for constructing an instance of
response
.Public Functions
-
inline explicit response_builder(http::status status)#
Construct a
response_builder
with specific HTTP status code.
-
inline auto set_status(http::status_code status) & noexcept -> response_builder&#
Set HTTP status code.
-
inline auto set_version(http::version version) & noexcept -> response_builder&#
Set HTTP version.
-
inline auto set_header(std::string_view name, std::string_view value) & -> response_builder&#
Set HTTP headers.
- DESCRIPTION
Set HTTP headers. The input
name
will be canonicalized before insertion. Note that any existing headers with the same name will be removed before the insertion.
-
inline auto set_header(http::field name, std::string_view value) & -> response_builder&#
Set HTTP headers.
- DESCRIPTION
Set HTTP headers. Note that any existing headers with the same name will be removed before the insertion.
-
inline auto insert_header(std::string_view name, std::string_view value) & -> response_builder&#
Insert HTTP headers.
- DESCRIPTION
Insert HTTP headers. The input
name
will be canonicalized before insertion. Note that any existing headers with the same name will be kept.
-
inline auto insert_header(http::field name, std::string_view value) & -> response_builder&#
Insert HTTP headers.
- DESCRIPTION
Insert HTTP headers. Note that any existing headers with the same name will be kept.
-
inline auto set_body() -> response#
Set a null body and create the
response
.- DESCRIPTION
Set a null body and create the
response
. If you do not want to modify the existing body, callbuild()
instead. Note that current object is no longer usable after calling this function.
-
template<std::size_t N>
inline auto set_body(std::span<const std::byte, N> bytes) -> response# Set a raw body and create the
response
.- DESCRIPTION
Set a raw body and create the
response
. Note that current object is no longer usable after calling this function.
-
inline auto set_body(std::string_view sv) -> response#
Set a raw body and create the
response
.- DESCRIPTION
Set a raw body and create the
response
. Note that current object is no longer usable after calling this function.
-
template<async_readable_stream AsyncReadableStream>
inline auto set_body(AsyncReadableStream &&stream) -> response# Set a raw body and create the
response
.- DESCRIPTION
Set a raw body and create the
response
. Note that current object is no longer usable after calling this function.
-
inline auto set_json(const boost::json::value &jv) -> response#
Set a json object as the body and create the
response
.- DESCRIPTION
Set a json object as the body and create the
response
.Content-Type: application/json
will be automatically inserted. Note that current object is no longer usable after calling this function.
-
template<typename T>
inline auto set_json(const T &obj) -> response# Set an object of type
T
that is converiable to a json object as the body and create theresponse
.- DESCRIPTION
Set an object of type
T
that is converiable to a json object as the the body and create theresponse
.Content-Type: application/json
will be automatically inserted. Note that current object is no longer usable after calling this function.
-
template<async_readable_stream AsyncReadableStream>
inline auto set_stream_body(AsyncReadableStream &&stream) -> response# Set a stream body and create the
response
.- DESCRIPTION
Set a stream body and create the
response
. A stream body will be sent withTransfer-Encoding: chunked
. Note that current object is no longer usable after calling this function.
-
inline explicit response_builder(http::status status)#