我正在使用cpp-netlib进行异步HTTP请求。文档中没有这方面的例子,导致我无法编译通过。我的当前尝试如下(注释中有编译错误)。您有什么提示可以使其正常工作吗?提前感谢您!
#include <iostream>
#include <boost/network/protocol/http/client.hpp>
using namespace std;
using namespace boost::network;
using namespace boost::network::http;
typedef function<void(boost::iterator_range<char const *> const &, boost::system::error_code const &)> body_callback_function_type; // ERROR: Expected initializer before '<' token
body_callback_function_type callback() // ERROR: 'body_callback_function_type' does not name a type
{
cout << "This is my callback" << endl;
}
int main() {
http::client client;
http::client::request request("http://www.google.com/");
http::client::response response = client.get(request, http::_body_handler=callback()); // ERROR: 'callback' was not declared in this scope
cout << body(response) << endl;
return 0;
}