I have not used cpp-netlib, but it looks like you have some obvious problems with your code:
The first error is the lack of boost:: typedef function.
typedef function<void(boost::iterator_range<char const *> const &, boost::system::error_code const &)> body_callback_function_type;
Must be
typedef boost::function<void(boost::iterator_range<char const *> const &, boost::system::error_code const &)> body_callback_function_type;
Second error:
body_callback_function_type callback() { cout << "This is my callback" << endl; }
There should be the right kind of function:
void callback( boost::iterator_range<char const *> const &, boost::system::error_code const &) { cout << "This is my callback" << endl; }
The third mistake is that you should pass the callback, not call it:
http::client::response response = client.get(request, http::_body_handler=callback());
Must be
http::client::response response = client.get(request, callback);
Hope this is all (or enough to get you started).
source share