en	BodyReader

en	A [*BodyReader] provides an online algorithm to transfer a series of zero or more buffers containing parsed body octets into a message container. The __parser__ creates an instance of this type when needed, and calls into it zero or more times to transfer buffers. The interface of [*BodyReader] is intended to allow the conversion of buffers into these scenarios for representation:

en	* Storing a body in a dynamic buffer * Storing a body in a user defined container with a custom allocator * Transformation of incoming body data before storage, for example

en	* Saving body data to a file

en	Associated Types

en	* [link beast.ref.boost__beast__http__is_body_reader `is_body_reader`] * __Body__

en	Requirements

en	These requirements may undergo non-backward compatible

en	In this table:

en	* `R` denotes a type meeting the requirements of [*BodyReader]. * `B` denotes a __Body__ where

en	* `a` denotes a value of type `R`. * `b` is an object whose type meets the requirements of __ConstBufferSequence__ * `h` denotes a value of type `header<isRequest, Fields>&`. * `v` denotes a value of type `Body::value_type&`. * `n` is a value of type `boost::optional<std::uint64_t>`. * `ec` is a value of type [link beast.ref.boost__beast__error_code `error_code&`].

en	Valid expressions

en	Expression

en	Type

en	Semantics, Pre/Post-conditions

en	`R{h,v};`

en	Constructible from `h` and `v`. The lifetime of `h` and `v` is guaranteed to end no earlier than after the `R` is destroyed. The reader shall not access the contents of `h` or `v` before the first call to `init`, permitting lazy construction of the message.

en	`a.init(n, ec)`

en	Called once to fully initialize the object before any calls to `put`. The message body is valid before entering this function, and remains valid until the reader is destroyed. The value of `n` will be set to the content length of the body if known, otherwise `n` will be equal to `boost::none`. Implementations of [*BodyReader] may use this information to optimize allocation. The function will ensure that `!ec` is `true` if there was no error or set to the appropriate error code if there was one.

en	`a.put(b,ec)`

en	`std::size_t`

en	This function is called to append some or all of the buffers specified by `b` into the body representation. The number of bytes inserted from `b` is returned. If the number of bytes inserted is less than the total input, the remainder of the input will be presented in the next call to `put`. The function will ensure that `!ec` is `true` if there was no error or set to the appropriate error code if there was one.

en	`a.finish(ec)`

en	This function is called when no more body octets are remaining. The function will ensure that `!ec` is `true` if there was no error or set to the appropriate error code if there was one.

en	`is_body_reader<B>`

en	`std::true_type`

en	An alias for `std::true_type` for `B`, otherwise an alias for `std::false_type`.

en	Exemplar

en	Models

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