Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Beast includes CRLF in HTTP fields
From: David Demelier (markand_at_[hidden])
Date: 2018-07-07 15:11:50


On Fri, 2018-07-06 at 08:31 -0700, Vinnie Falco via Boost-users wrote:
> > 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.

Okay, maybe I'm stupid or I don't understand something.

I've done a simple request to google.fr and the
http::response[field::location] still has CRLF even with the following
code using value_type's value() function:

    if (res_.result() == status::moved_permanently) {
        const auto it = res_.find(field::location);

        if (it != res_.end())
            cout << "new location: [" << it->value << "]" << std::endl;
    }

The res_ object is a http::response<http::string_body>, And once
printed to the console I have:

    new location: [http://www.google.fr/
    ]

May I miss something from your original answer?

Regards,

-- 
David

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