What C++ library should I use to implement a HTTP client?

Piotr Dobrogost picture Piotr Dobrogost · May 5, 2009 · Viewed 80.5k times · Source

I'm looking for a C++ library that implements or enables the implementation of a HTTP client. It should handle cookies as well.

What would you propose?

Answer

bdonlan picture bdonlan · May 5, 2009

Curl++: is an option, particularly if you want things in more of a C++ style.

cpp-netlib: very good and simple to use, available on ubuntu

sudo apt-get install libcppnetlib-dev

example:

using namespace boost::network;
using namespace boost::network::http;

client::request request_("http://127.0.0.1:8000/");
request_ << header("Connection", "close");
client client_;
client::response response_ = client_.get(request_);
std::string body_ = body(response_);