On Sat, 2018-07-07 at 08:20 -0700, Vinnie Falco via Boost-users wrote:
> On Sat, Jul 7, 2018 at 8:11 AM, David Demelier via Boost-users
> <email@example.com> wrote:
> > The res_ object is a http::response<http::string_body>, And once
> > printed to the console I have:
> > new location: [http://www.google.fr/
> > ]
> Hmm...that's not what I'm seeing. I added this function to
> request<empty_body> req;
> req.insert(field::location, "http://www.google.fr/");
> auto it = req.find(field::location);
> if(it != req.end())
> log << "[" << it->value() << "]";
> The output is:
> [http://www.google.fr/]25.6s, 1 suite, 1 case, 334 tests total, 0
> The program '[0x6BF4] tests-beast-http.exe' has exited with code
> 0 (0x0).
> If the CRLF was being included in the value, then none of these tests
> would pass, as the equalities would evaluate to false:
My bad, I apologize I wrongly converted the boost::string_view to
std::string using the .data() member function and I just realized it's
not null terminated... That's why my string was filled with random
Why do you use data() without using size()/length() ?
with string_view this is a recipe for hard to find bugs.
At my job I've seen same behavior, and I am trying to explain to people that data() in std::string & std::string_view is mostly for C interfaces.
Sorry for the noise!
I should search how people convert boost::string_view to std::string in
a convenient manner instead ;)
Boost-users mailing list