C ++ Boost 1.66使用Beast http请求解析器解析字符串 [英] C++ Boost 1.66 using Beast http request Parser for parsing an string

查看:987
本文介绍了C ++ Boost 1.66使用Beast http请求解析器解析字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm not using beast http server in my project but I was searching for a solution to parse an http request in form of std::string in my program ,is it possible to use boost/beast/http/parser.hpp in this case and if so it would be Great if you give an example in code. Thanks aloot

推荐答案

是可以的:

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);

这篇关于C ++ Boost 1.66使用Beast http请求解析器解析字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆