如何从响应中只读正文

How to read only body from response

本文关键字:只读 正文 响应      更新时间:2023-10-16

我看到的阅读响应的示例如下所示。但这会打印出响应标头以及响应正文。野兽是否暴露了一种仅将身体作为绳子的方法?我看起来可以访问res.body但我不确定如何获取并转换它。

// Declare a container to hold the response
http::response<http::dynamic_body> res;
// Receive the HTTP response
http::read(socket, buffer, res);
// Write the message to standard out
std::cout << res << std::endl;

使用 htpp::string_body 而不是 http::dynamic_body 然后获取 res.body