On Fri, 6 Jul 2018 at 17:32, Vinnie Falco via Boost-users <boost-users@lists.boost.org> wrote:
On Fri, Jul 6, 2018 at 3:45 AM, David Demelier via Boost-users
<boost-users@lists.boost.org> wrote:
> It looks like HTTP response headers are saved with trailing CRLF in the
> message upon receiption after (async_)read.

Yes, beast::http::basic_fields stores each field/value pair in its
serialized format, which includes the trailing CRLF and also the colon
and space. It is done this way so that beast::http::serializer
requires no memory allocations to perform its function.

> Since it usually does not add additional valuable information, would it
> be possible to remove them in next version of Boost.Beast?


> It will be more convenient as you don't need to trim them when you want
> to capture the field value.

You shouldn't have to do any trimming. basic_fields member functions
and iterator value_type which return field values do so using a
string_view, whose length excludes the trailing CRLF and also any
colon and space. Callers should not assume the string is
null-terminated, and work with the interface provided by string_view.



Out of interest, why do these functions return a const string_view?

Boost-users mailing list