Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

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.

Associated Types
Requirements

In this table:

Table 1.28. Valid expressions

Expression

Type

Semantics, Pre/Post-conditions

B::value_type

The return type of the message::body member function. If this is not movable or not copyable, the containing message will be not movable or not copyable.

B::reader

If present, indicates that the body can be parsed. The type must meet the requirements of BodyReader. The implementation constructs an object of this type to obtain buffers into which parsed body octets are placed.

B::writer

If present, indicates that the body is serializable. The type must meet the requirements of BodyWriter. The implementation constructs an object of this type to obtain buffers representing the message body for serialization.

B::size(
  B::value_type body)

std::uint64_t

This static member function is optional. It returns the payload size of body in bytes not including any chunked transfer encoding. The return value may be zero, to indicate that the message is known to have no payload. The function shall not exit via an exception.

When this function is present:

* The function shall not fail

* A call to message::payload_size will return the same value as size.

* A call to 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 message::payload_size will return boost::none.

* A call to 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.


Exemplar
struct Body
{
    // The type of message::body when used
    struct value_type;

    /// The algorithm used during parsing
    class reader;

    /// The algorithm used during serialization
    class writer;

    /// Returns the body's payload size
    static
    std::uint64_t
    size(value_type const& body);
};

static_assert(is_body<Body>::value, "");
Models

PrevUpHomeNext