[/
    Copyright (c) 2016-2019 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)

    Official repository: https://github.com/boostorg/beast
]

[section:Body 消息体]

[*Body] 类型作为模板参数传递给 __message__ 类。它决定结果消息对象中数据成员的类型，以及解析和序列化所用算法。

[heading 关联类型]

* [link beast.ref.boost__beast__http__is_body `is_body`]
* __BodyReader__
* __BodyWriter__

[heading 要求]

在下表中：

* `B` 是一个满足 [*Body] 要求的类型。
* `m` 是类型为 `message<b,B,F>` 的值，其中 `b` 为 `bool` 类型的值。
  and `F` is a type meeting the requirements of __Fields__.

[table 有效表达式
[[表达式] [类型] [语义、前置条件与后置条件]]
[
    [`B::value_type`]
    []
    [`message::body` 成员函数返回的类型。如果该类型不支持移动或复制，则包含它的消息对象同样不支持移动或复制。]
][
    [`B::reader`]
    []
    [若该类型存在，则表示消息体可被解析。该类型必须满足 __BodyReader__ 的要求。实现会构造该类型的对象，用于获取存放已解析消息体八位字节的缓冲区。]
][
    [`B::writer`]
    []
    [若存在该类型，则用于表示该主体可序列化。该类型必须满足 __BodyWriter__ 的要求。该实现用于构造该类型的对象，以获取用于表示消息主体序列化内容的缓冲区。]
][
    [
    ```
    B::size(
      B::value_type body)
    ```
    ]
    [`std::uint64_t`]
    [该静态成员函数为可选。它返回消息体的大小（以字节为单位），不包含任何分块传输编码。返回值可能为零，表示已知消息不包含有效载荷。该函数不应通过异常退出。

当该函数存在时：

* 函数不应失败。
* 调用 [link beast.ref.boost__beast__http__message.payload_size `message::payload_size`] 将返回与 `size` 相同的值。
* 调用 [link beast.ref.boost__beast__http__message.prepare_payload `message::prepare_payload`] 将移除 Transfer-Encoding 字段中的 "chunked"（如果它作为最后一个编码出现），并将 Content-Length 字段设置为返回的值。

否则，当该函数省略时：

* 调用 [link beast.ref.boost__beast__http__message.payload_size `message::payload_size`] 将返回 `boost::none`。
* 调用 [link beast.ref.boost__beast__http__message.prepare_payload `message::prepare_payload`] 将擦除 Content-Length 字段，并在 Transfer-Encoding 字段中添加 "chunked" 作为最后一个编码（如果尚未存在）。]
]]

[heading 示例]

[concept_Body]

[heading 模型]

* [link beast.ref.boost__beast__http__basic_dynamic_body `basic_dynamic_body`]
* [link beast.ref.boost__beast__http__basic_file_body `basic_file_body`]
* [link beast.ref.boost__beast__http__basic_string_body `basic_string_body`]
* [link beast.ref.boost__beast__http__buffer_body `buffer_body`]
* [link beast.ref.boost__beast__http__empty_body `empty_body`]
* [link beast.ref.boost__beast__http__span_body `span_body`]
* [link beast.ref.boost__beast__http__vector_body `vector_body`]

[endsect]
