boost http request_parser正文始终为空?

时间:2019-05-13 14:26:05

标签: c++ http parsing boost request

任何人都经历过boost :: beast :: http :: request_parser p; p.get()。body()总是为空,而我看到请求的格式正确吗?如果您有该课程的经验,可能会有什么问题?

.base()是页眉部分,当正文始终为空时可以正确打印...

boost::system::error_code ec;
boost::beast::http::request_parser<boost::beast::http::string_body> p;
std::cout<<std::string(data)<<std::endl;
p.put(boost::asio::buffer(data), ec);
std::cout<<p.get().base()<<std::endl;
std::cout<<p.get().body()<<std::endl;`

解析的字符串数据如下:

POST / HTTP/1.1
Host: 127.0.0.1:8812
User-Agent: curl/7.54.0
Accept: */*
Content-Length: 182
Content-Type: application/x-www-form-urlencoded

{
"to_address": "41e552f6487585c2b58bc2c9bb4492bc1f17132cd0",
"owner_address":"41e472f387585c2b58bc2c9bb4492bc1f17342cd1", 
"amount":100, 
"asset_name":"3230313271756265696a696e67"
}

0 个答案:

没有答案