The C++ REST SDK (“Casablanca”)
The C++ REST SDK (codename “Casablanca”) has officially been released as an open source project on CodePlex (http://casablanca.codeplex.com). It includes tools to quickly write modern, asynchronous C++ code that connects with REST services.
It makes it much more easy to write application in C++ that use networking. Here is a simple example that uploads a file to an HTTP Server:
#include <http_client.h> #include <filestream.h> #include <uri.h> #include <thread> #pragma comment(lib, "casablanca110") using namespace concurrency::streams; using namespace web::http::client; using namespace web::http; int main() { // Open stream to file. file_stream<unsigned char>::open_istream(L"ReadMe.txt").then([](basic_istream<unsigned char> fileStream) { // Make HTTP request with the file stream as the body. http_client client(U("http://www.myhttpserver.com")); client.request(methods::PUT, L"myfile", fileStream).then([fileStream](http_response response) { fileStream.close(); // Perform actions here to inspect the HTTP response... if (response.status_code() == status_codes::OK) { } }); }); std::this_thread::sleep_for(std::chrono::seconds(10)); return 0; }
The library also makes it easy to create and consume JSON formatted strings from C++.
Checkout this blog post for a little bit more details.