/// An HTTP message template< bool isRequest,// `true` for requests, `false` for responses class Body,// Controls the container and algorithms used for the body class Fields = fields>// The type of container to store the fields class message;
The container offers value semantics including move and copy if supported by __Body__ and __Fields__. User defined template function parameters can accept any message, or can use partial specialization to accept just requests or responses. The default __fields__ is a provided associative container using the standard allocator and supporting modification and inspection of fields. As per __rfc7230__, a non-case-sensitive comparison is used for field names. User defined types for fields are possible. The `Body` type determines the type of the container used to represent the body as well as the algorithms for transferring buffers to and from the container. The library comes with a collection of common body types. As with fields, user defined body types are possible.
Sometimes it is desired to only work with a header. Beast provides a single class template __header__ and some aliases to model HTTP/1 and HTTP/2 headers:
/// An HTTP header template< bool isRequest,// `true` for requests, `false` for responses class Fields = fields>// The type of container to store the fields class header;
Requests and responses share the version, fields, and body but have a few members unique to the type. This is implemented by declaring the header classes as partial specializations of `isRequest`. __message__ is derived from __header__; a message may be passed as an argument to a function taking a suitably typed header as a parameter. Additionally, `header` is publicly derived from `Fields`; a message inherits all the member functions of `Fields`. This diagram shows the inheritance relationship between header and message, along with some of the notable differences in members in each partial specialization:
Beast defines the __Body__ concept, which determines both the type of the [link beast.ref.boost__beast__http__message.body `message::body`] member (as seen in the diagram above) and may also include algorithms for transferring buffers in and out. These algorithms are used during parsing and serialization. Users may define their own body types which meet the requirements, or use the ones that come with the library: