cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Automatic use of http_proxy environment variable

From: <andrei_at_korostelev.net>
Date: Tue, 16 Sep 2014 15:37:40 +0200

> On Tue, 16 Sep 2014, andrei_at_korostelev.net wrote:
>
>> We have an app which we distribute to Windows and Linux and which makes
>> use
>> of libcurl. The app allows to setup proxy in config file. However when
>> http_proxy env. variable is set it comes into a conflict with
>> app-specific
>> proxy settings. This is especially annoying for Windows users.
>
> Can't you then just set the proxy if there is one, and set it to "" if you
> explicitly do not want one? I can't think of a situation where this would
> be
> unclear. Can you?

Normally if the app is configured not to use proxy, it simply calls
curl_easy_perform();
which is clean and logical.

With your suggestion we shall first do this prelude:

curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLPROXY_HTTP);
curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
curl_easy_setopt(cutl, CURLOPT_PROXY, "");

and then call
curl_easy_perform(curl);

Right?

Technically it will probably achieve a right result (proxy will be
disabled) but it looks unnecessary over-complicated.
Don't you think so?

>
>> The solution I propose is very simple. Since all proxy-detection magic
>> lives
>> in detect_proxy() function in url.c, we can easily call this function
>> conditionally:
>>
>> #ifdef CURL_ENABLE_PROXY_DETECTION
>> proxy = detect_proxy(conn);
>> #endif
>
> If a disable switch really is necessary, I would think it should be
> possible
> to set at run-time and not require a special build!
>

That's even better.

> --
>
> / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-09-16