I am looking for a modern C++ HTTP library because libcurl's shortcomings are difficult to work around by C++ wrappers. Solutions based on Boost.ASIO, which has become the de-facto C++ TCP library, are preferred.
问题:
回答1:
The other day somebody recommended this on another thread:
I think this is as high-level as you will find, but I'm not sure if it's mature enough yet (I would say it probably is since they've proposed it for Boost inclusion).
回答2:
Better late than never, here's a new answer to an old question. There's this new open source library called Boost.Beast which offers both HTTP and WebSocket functionality using Boost.Asio. It emulates the familiar Asio interfaces as closely as possible, and its got plenty of documentation. It builds on clang, gcc, and Visual Studio using either bjam or CMake - your choice! Note, I am also the author of the library.
https://github.com/boostorg/beast/
Here's a complete example program that retrieves a web page:
#include #include #include #include #include #include #include #include using tcp = boost::asio::ip::tcp; // from namespace http = boost::beast::http; // from // Performs an HTTP GET and prints the response int main(int argc, char** argv) { try { // Check command line arguments. if(argc != 4 && argc != 5) { std::cerr []\n" req{http::verb::get, target, version}; req.set(http::field::host, host); req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); // Send the HTTP request to the remote host http::write(socket, req); // This buffer is used for reading and must be persisted boost::beast::flat_buffer buffer; // Declare a container to hold the response http::response<:dynamic_body> res; // Receive the HTTP response http::read(socket, buffer, res); // Write the message to standard out std::cout
回答3:
asio author implement:
回答4:
You should also check out the Pion Network Library:
回答5:
Boost.Http - a new player here: https://github.com/BoostGSoC14/boost.http, docs - http://boostgsoc14.github.io/boost.http/
回答6:
There's this project trying to "Boostify" libcurl: https://github.com/breese/trial.url
I'll use this as a reference to design Boost.Http client API. However, I plan to focus on high-level abstractions and try to collaborate as much as possible with Beast.HTTP author.