Plans to add parameter parsing in Beast?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Plans to add parameter parsing in Beast?

Boost - Users mailing list
Hello,

I'm trying to use Beast, it works fine and looks promising.
Unfortunately, it looks like (unless I'm wrong) that there is no
facilities to parse URL parameters or POST data. Such as

    /foo&option1=1&option2=2

Or simply form data:

    option1=1&option2=2

Are there plans to add such things or is definitely a non-goal of Boost
Beast?

Regards,

--
David
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Plans to add parameter parsing in Beast?

Boost - Users mailing list
On Tue, May 29, 2018 at 1:23 AM, David Demelier via Boost-users
<[hidden email]> wrote:
> Are there plans to add such things or is definitely a non-goal of Boost
> Beast?

Yes, a uri parser/serializer is a planned feature. No timeline on that yet.
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Plans to add parameter parsing in Beast?

Boost - Users mailing list
On Tue, 2018-05-29 at 13:06 -0700, Vinnie Falco via Boost-users wrote:
> Yes, a uri parser/serializer is a planned feature. No timeline on
> that yet.

FWIW, I have tried some encode/decode at the moment:

#include <cctype>
#include <ios>
#include <iomanip>
#include <sstream>
#include <stdexcept>

#include "uri.hpp"

namespace uri {

std::string encode(const std::string& input)
{
    std::ostringstream oss;

    for (auto c : input) {
        if (std::isalnum(c) || c == '-' || c == '_' || c == '.' || c ==
'~')
            oss << c;
        else {
            oss << "%";
            oss << std::hex << std::uppercase << std::setw(2);
            oss << static_cast<int>(static_cast<unsigned char>(c));
            oss << std::nouppercase;
        }
    }

    return oss.str();
}

std::string decode(const std::string& input)
{
    std::ostringstream oss;

    for (auto it = input.cbegin(); it != input.cend(); ) {
        if (*it != '%')
            oss << *it++;
        else {
            if (input.end() - it < 3)
                throw std::invalid_argument("truncated string");

            const auto substr = input.substr(it - input.begin() + 1,
2);

            oss << static_cast<char>(std::stoull(substr, nullptr, 16));
            it += 3;
        }
    }

    return oss.str();
}

} // !uri

Regards,

--
David
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users