Files
boost_beast/doc/concept/Body.qbk
T

107 lines
3.3 KiB
Plaintext

[/
Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
]
[section:Body Body]
A [*Body] type is supplied as a template argument to the __message__ class. It
controls both the type of the data member of the resulting message object, and
the algorithms used during parsing and serialization.
In this table:
* `X` is a type meeting the requirements of [*Body].
* `m` is a value of type `message<b, X, F>` where `b` is a `bool` value
and `F` is a type meeting the requirements of [*Fields].
[table Body requirements
[[expression] [type] [semantics, pre/post-conditions]]
[
[`X::value_type`]
[]
[
The type of the `message::body` member.
If this is not movable or not copyable, the containing message
will be not movable or not copyable.
]
][
[`X::writer`]
[]
[
If present, indicates that the body can hold a message body
parsing result. The type must meet the requirements of
__BodyWriter__. The implementation constructs an object of
this type to obtain buffers into which parsed body octets
are placed.
]
][
[`X::reader`]
[]
[
If present, indicates that the body is serializable. The type
must meet the requirements of __BodyReader__. The implementation
constructs an object of this type to obtain buffers representing
the message body for serialization.
]
][
[`X::size(X::value_type v)`]
[`std::uint64_t`]
[
This static member function is optional. It returns the payload
size of `v` not including any chunked transfer encoding. The
function shall not exit via an exception.
When this function is present:
* The function shall not fail
* A call to
[link beast.ref.beast__http__message.payload_size `message::payload_size`]
will return the same value as `size`.
* A call to
[link beast.ref.beast__http__message.prepare_payload `message::prepare_payload`]
will remove "chunked" from the Transfer-Encoding field if it appears
as the last encoding, and will set the Content-Length field to the
returned value.
Otherwise, when the function is omitted:
* A call to
[link beast.ref.beast__http__message.payload_size `message::payload_size`]
will return `boost::none`.
* A call to
[link beast.ref.beast__http__message.prepare_payload `message::prepare_payload`]
will erase the Content-Length field, and add "chunked" as the last
encoding in the Transfer-Encoding field if it is not already present.
]
][
[`is_body<X>`]
[`std::true_type`]
[
An alias for `std::true_type` for `X`, otherwise an alias
for `std::false_type`.
]
]
]
[heading Exemplar]
[concept_Body]
[heading Models]
* [link beast.ref.beast__http__basic_dynamic_body `basic_dynamic_body`]
* [link beast.ref.beast__http__buffer_body `buffer_body`]
* [link beast.ref.beast__http__dynamic_body `dynamic_body`]
* [link beast.ref.beast__http__empty_body `empty_body`]
* [link beast.ref.beast__http__string_body `string_body`]
* [link beast.ref.beast__http__string_view_body `string_view_body`]
[endsect]