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
Asked
Active
Viewed 3,978 times
1 Answers
3
Yes it is possible:
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);

Vinnie Falco
- 5,173
- 28
- 43
-
```bad method``` is written to the ```error_code``` in your example. (boost 1.68) – Marat Gareev Oct 02 '18 at 14:48
-
1Whoops, sorry about that! The string contained an HTTP response instead of a request. I have updated the code sample. – Vinnie Falco Oct 03 '18 at 12:28