c++boostnetwork-programmingcpp-netlib

how to set a flag (cpp-netlib)


I think my question is really trivial, but I can't get it to work nonetheless

std::string url="www.google.it";

boost::network::http::client client1_(_follow_redirects=true, _cache_resolved=true);
boost::network::http::client::request req(url);
boost::network::http::client::response resp = client1_.get(req);
std::cout << "Body: " << body(resp) << std::endl;

return 0;

the error of course refers to the declaration of the flags...but how can I set them?

/home/snake91/cpp_pricing/underlying.cpp:67: error: C++ requires a type specifier for all declarations
    boost::network::http::client client1_(_follow_redirects=true, _cache_resolved=true);

^

Solution

  • client::options options;
    options.follow_redirects(true)
           .cache_resolved(true);
    
    client client1_(options);
    

    From this page of the docs: http://cpp-netlib.org/0.11.0/reference/http_client.html#general