C++ HTTP requests API - c++

I'm rewriting a Java project in C++ where I used okhttp. Is there a similar lib to easily send GET/POST requests? I tried to setup cURLpp but can't find a guide to compile it.

You can try to use cpp-netlib based on C++11

Related

How can I connect my C++ application with an node.js server to get JSON data?

It's pretty much the tittle.
Im not expecting the whole code to just copy and paste (but feel free to do it). Im just having difficulties to find some data related. If someone knows how to do it, please post some hints, article links, specific words to make some research on it.
Thank you.
As Christian mentioned in his comment, your problem can be solved by implementing an HTTP client that parses JSON responses, independently of the technology used by your server. To do this in C++, I would refer you to the following resources:
High-level library for C++ HTTP client.
libcurl (lower level library for HTTP requests).
RapidJSON library to parse the responses you will get from your server (see this benchmark for a comparison of JSON parsing libraries).
If your C++ application uses a framework such as Qt, it likely includes facilities for requests (e.g. Qt HTTP example).
On the server side, you will have to define HTTP endpoints that return the data you are interested in, encoded as JSON. The beginning of this tutorial shows an easy way to do that.
node.js c++ add on manual
https://nodejs.org/api/addons.html
http://libuv.org/
use libuv function in node.js 0.12.x

how to set proxy credentials in the websocket client code using boost

I am new to boost lib. I need a client program which will communicate with the server even in proxy environment also. I have tried with the poco lib,in that i got struck at creation of web socket after Handshake. After i am trying with this boost package and i have downloaded a sample chat client program from the boost examples.In that i don't know where to set proxy requirements. I searched in the all .cpp file inside the boost package. But i didn't understand any thing.
Can any body plz help me whether it is possible to do client communication in proxy environment with this.if it is possible tell me how.if not with this,please suggest any possible way.
Thanks,
vvk.
Boost Asio does not have proxy support.
I'd use libcurl for this myself. Libcurl has some integrations with Boost Asio floating around on github.
There's also CppNetlib which (undoubtedly) will have proxy support, and is integrated with Boost Library like Asio is (although it's not a part of the boost library distribution like Asio is).
Lastly, there's some hints on getting "manual" proxying started using just Boost Asio here:
how to add proxy support to boost::asio?
Although this will leave you implementing your own authentication too :/

C++ Library with http 1.1 response caching support

I am working on a project where I need to communicate with a server using a network library in C++. Currently im using POCO/Net
Is there any C++ library that has support for response caching, authentication, HTTP and HTTPS similar to the Java version?
Greatful for help!
wwwlib seems to provide the kind of persistant cache you are after and is http 1.1 compliant according to W3lib. I have not yet tried it though, it seems very low level in comparison to POCO. Someone else might have a simpler library...

What direction should I follow to add webservice functionalities to my application?

I have a problem, and I know there are many ways to solve it. I hope you can help me chose the fittest.
I am developping an application mainly using Matlab, and I try to gradually shift some of its functionalities to c++. I develop on windows, for windows.
I am quite experienced in these two programming languages, but I know nothing of web development.
I want to add some functionalities to this application that will use some webservices hosted on a server protected by ssl.
I am alone on this project, but I can spend some time learning new stuff if need be.
I would like to know what tools you think I should better use for this task ?
So far, I have tried and failed the following approach :
calling the webservice directly from Matlab. I have added the self-signed ssl certificate to every truststore I could find on my computer, but I keep getting an error telling me that the certificate is not valid.
calling the webservice using gSoap and c++. For this, I need to rebuild the gSoap binaries with ssl capabilities. I tried too do so using visual studio and mingw/gcc but did not succeed, and I could not find any help online.
I have the feeling after a few hours/days browsing and looking for solution that the tools I try to use are not the most used and therefore not the best documented (and therefore not the best suited for a rookie), so what is your advice?
I think using gSoap from your C++ modules would be the best choice.
Information about using gSoap with SSL as client is available here: Secure SOAP Clients with HTTPS/SSL
A link about using gSoap for building a VS Application: Creating a gSoap eBay Client Application with Visual C++ 2008
May be this helps for using gSoap with MinGW: Using gSoap in Qt/Windows

How i can send an HttpRequest from C++

I'm using DataServices and OData protocol. I need to generate HTTP Get, Post, Delete, and Update from a C++ application. How I can do this? What is the easiest way?
Try cURL. check out this SO post. Perform a simple HTTP request using C++ / Boost via a proxy?
Boost.Asio. There's an example of a simple HTTP client (with a GET request).
The POCO library is another alternative to cURL
You can use MS stuff: Wininet or WinHTTP.
Adding to this old post.
Beast is a cross-platform, header-only, modern C++11 library built on Boost.Asio that provides implementations of the HTTP and WebSocket protocols.
The project is under evaluation to be included in Boost, so it may be worth looking at it.