curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to use libcurl with a config file?

From: Daniel Stenberg via curl-library <curl-library_at_cool.haxx.se>
Date: Fri, 22 Mar 2019 22:51:26 +0100 (CET)

On Wed, 20 Mar 2019, Rich Megginson via curl-library wrote:

> I'm writing a C application (rsyslog) which uses libcurl and I would like to
> be able to pass in a lot of parameters to libcurl without having to
> implement support for every single option to pass in separately to
> curl_easy_setopt().  The curl cli has a -K option which you can use to pass
> in a config file, but it doesn't look as though this is part of the public
> API, and there is no option like CURLOPT_CONFIG_FILE for curl_easy_setopt().
>
> Any suggestions?  I'm thinking to just copy/paste big chunks of
> src/tool_getparam.c and src/tool_operate.c

(I noticed you also posted this as an issue, with some additional details over
at https://github.com/curl/curl/issues/3698 but we don't do feature requests
there so expect that one to close soon.)

As you have figured out, there is no libcurl code around for parsing the
config file. That's done entirely by the application.

I think it is an interesting idea to move the config parser into the library.
Or perhaps, into *a* library. I haven't thought this through really, but maybe
it would make sense to have a dedicated "curlconfig" library whose only
purpose would be to read a curl config and set libcurl options?

It would keep the config file out of the library and not increase its
footprint or complexity, but still offer the functionality in library form.

-- 
  / daniel.haxx.se

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2019-03-22