Le sam. 7 juil. 2018 à 11:34, David Demelier via Boost-users < boost-users@lists.boost.org> a écrit :
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
wrote: The res_ object is a http::responsehttp::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 test/beast/http/fields.cpp:
void testValue() { request
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:
beast.http.fields [http://www.google.fr/]25.6s, 1 suite, 1 case, 334 tests total, 0 failures 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 characters.
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 ;)
Regards,
-- David _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Daniel «Il faut imaginer Sisyphe heureux» Albert Camus