gpt4 book ai didi

c++ - "Body requirements not met"将请求传递给 c++ 中的方法(Boost Beast 库)

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

我正在尝试将请求传递给方法。我的代码是:

void handle_request(boost::beast::string_view doc_root, http::request<http::string_body> req, Send send)
{
some code here
}

但是当我尝试编译它时,出现了这个错误:

  "Body requirements not met"

我该如何解决?

错误不是来自这些行,但如果我从代码中删除函数定义,它不会显示任何错误。

还有其他几个错误全部来自

beast\http\message.hpp.

最佳答案

该消息可能是 is_body 概念检查的结果。

您显示的代码不会导致错误,如该片段所示:

Live On Coliru

#include <boost/beast.hpp>
#include <boost/beast/http/type_traits.hpp>

int main() {
using namespace boost::beast;

http::request<http::string_body> req;

static_assert(http::is_body<http::string_body>::value, "all good");
}

如果这不能为您编译,那么要么是您的 Boost 源已损坏,要么是您的编译器被误导了。

更有可能的是您没有提到实际触发错误的代码,或者您没有编译您在编辑器中看到的代码。

关于c++ - "Body requirements not met"将请求传递给 c++ 中的方法(Boost Beast 库),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52061373/

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