Boost Users :
Subject: Re: [Boost-users] Boost.Beast includes CRLF in HTTP fields
From: Vinnie Falco (vinnie.falco_at_[hidden])
Date: 2018-07-06 15:31:52
On Fri, Jul 6, 2018 at 3:45 AM, David Demelier via Boost-users
> 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.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net