c++curllibcurl

Loading curl config file through curl API


I'm using libcurl API in a C++11 application. Since curl has several options, I would like the application to be able to load all of the options from a configuration file. I saw that the command-line curl application can do this: https://everything.curl.dev/cmdline/configfile.html

However, when looking through the API, and even browsing a bit through the source code, I could not find an easy way of setting all my curl handle's options through a file. Something like:

curl_load_file(CURL * curl, const char* filePath);

or similar. I'm thinking of starting a project of my own that would do this, but it really feels that I am reinventing the wheel.

Is there any easy way of doing this? How?


Solution

  • libcurl has no API for loading config options from a file. The curl application implements logic to parse a file and make the appropriate API calls. You will have to do the same in your application.