Search code examples
c++curlboostboost-asio

Sending http GET request using boost::asio, similar to cURL


I'm trying to send a http GET request using the REST API of some domain. Basically what I'm trying to do is to replace following curl request:

    curl -k  -H "Content-Type: application/json" -X GET 
--data '{"username":"[email protected]", "password":"test"}' https:/domain.name/api/login/

with some c++ code using boost::asio. I do not what to find all c++ code here , but some checkpoints would be great.


Solution

  • boost::asio is not an application level library. So you can open a connection with it, do an SSL handshake and so on. But you cannot construct HTTP requests via boost::asio since it's designed to just send/receive data.

    But, you can try to experiment with this asio HTTP client example. Probably this can be a good thing to start with.