Plans to add parameter parsing in Beast?
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
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
participants (2)
-
David Demelier
-
Vinnie Falco