C++ Boost 1.66 使用 Beast http 请求解析器解析字符串

C++ Boost 1.66 using Beast http request Parser for parsing an string

本文关键字:请求 字符串 http Beast Boost 使用 C++      更新时间:2023-10-16
我没有在我的项目中使用 beast http

服务器,但我正在寻找一种解决方案来解析我的程序中以 std::string 的形式解析 http 请求,是否可以在这种情况下使用 boost/beast/http/parser.hpp,如果是这样,如果你在代码中给出一个示例,那就太好了。谢谢阿鲁特

是的,有可能:

std::string s =
    "POST /cgi/message.php HTTP/1.1rn"
    "Content-Length: 5rn"
    "rn"
    "abcde";
error_code ec;
request_parser<string_body> p;
p.put(boost::asio::buffer(s), ec);