c++ - 如何在 beast 1.7 中打印 http 消息

标签 c++ boost boost-beast

我无法打印 http 请求的基础,因为迁移到 beast 1.70.0

我之前是通过以下方式完成的:

std::cerr << ctx.res.base()

但目前看起来运算符没有重载,如何在 1.70.0 中重载?

问题可以通过以下代码重现:(注意应该使用 beast 1.70.0)

#include <boost/beast/http.hpp>
#include <boost/beast/http/write.hpp>
#include <iostream>

using namespace boost::beast;

http::response<http::string_body> res {};

int main()
{
    std::cout << res.base();
}

最佳答案

这是 Boost 1.70 中的错误,已在 1.71 版中修复。解决方法是为您的构建定义宏 BOOST_BEAST_ALLOW_DEPRECATED

关于c++ - 如何在 beast 1.7 中打印 http 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57574182/

相关文章:

c++ - 从 C++ 在 QML 中设置对象类型属性

c++ - Qt - 如何解决 QScroller 最大尺寸限制(16777215 像素)

c++ - 为什么 std::lock() 支持避免死锁但 std::try_lock() 不支持?

c++ - 将 boost::shared_ptr 与 WSACleanup 结合使用

http - Boost beast websocket 服务器异步接受失败,缓冲区溢出

c++ - 为什么我可以在 C 中分配/比较 int 和 char

c++ - 尽管一切看起来都正确,为什么 boost::serialize 不起作用? ("unregistered class")

python - 如何使用 boost.python 将预填充的 "unsigned char*"缓冲区传递给 C++ 方法?

c++ - 使用Boost野兽和openssl的async_handshake发生内存泄漏