Any hints how to implement a simple asynchronous client using cpp-netlib? I assume, it won't be as long as boost asio async client. Code sample will be helpful. My pathetic attempt is below.
#include <iostream>
#include <string>
#include <boost/network/protocol/http/client.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/network/protocol/http/response.hpp>
#include <boost/network/protocol/http/client/connection/connection_delegate_factory.hpp>
#include <boost/network/protocol/http/traits/delegate_factory.hpp>
#include <boost/network/protocol/http/client/connection/async_normal.hpp>
using namespace std;
using namespace boost::network;
using namespace boost::network::http;
typedef boost::function<void(boost::iterator_range<char const *> const &, boost::system::error_code const &)> body_callback_function_type;
typedef boost::iterator_range<char const *> rValue;
std::string res;
void callback(boost::iterator_range<char const *> const & a, boost::system::error_code const & b)
{
for(rValue::difference_type i = 0; i < a.size(); ++i)
{
res += a[i];
}
}
int main() {
http::client client;
http::client::request request("http://www.blekko.com/");
http::client::response response = client.get(request, callback);
while (!ready(response));
cout << res << endl;
return 0;
}