gpt4 book ai didi

c++ - 如何从响应中只读取正文

转载 作者:太空宇宙 更新时间:2023-11-04 12:56:04 24 4
gpt4 key购买 nike

我看到的阅读响应的示例如下所示。但这会打印出响应 header 和响应主体。 Beast 是否公开了一种将 body 作为字符串获取的方法?看起来可以访问 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

关于c++ - 如何从响应中只读取正文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46627481/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com