4

我没有在我的项目中使用野兽 http 服务器,但我正在寻找一种解决方案来在我的程序中以 std::string 的形式解析 http 请求,是否可以在此使用 boost/beast/http/parser.hpp如果是这样的话,如果你在代码中给出一个例子,那就太好了。非常感谢

4

1 回答 1

3

对的,这是可能的:

std::string s =
    "POST /cgi/message.php HTTP/1.1\r\n"
    "Content-Length: 5\r\n"
    "\r\n"
    "abcde";
error_code ec;
request_parser<string_body> p;
p.put(boost::asio::buffer(s), ec);
于 2018-04-10T15:05:30.203 回答