Make POST request with Boost Asio

I’m trying to write C++ bindings for LibreTranslate with minimal dependencies. It looks like networking isn’t in the standard library (maybe in 23?), so I’ve been trying to use Boost.

How involved is it to make a POST request using Boost Asio? I found this example, but this is a very manual process and I don’t think it’s doing SSL. Rolling your own network parsing seems risking and potentially insecure but is that the best solution?

Just my two cents, I would strongly recommend using libcurl to do anything network related in C++. Yes the API is a bit verbose, but you have lots of wrappers if you want a more object-oriented interface to it and the library is rock solid.
I personally link to libcurl and then write my own simple wrapper for the operations I need, like in DroneDB/request.cpp at master · DroneDB/DroneDB · GitHub

The examples are the best documentation:

Edit: I would definitely not write my own http parser. Maybe if SSL wasn’t a requirement it would be an option (and a fun experience).

1 Like

Thanks for the info!

1 Like