curl-library
Re: CURLOPT_PROXY and --disable-http
Date: Wed, 19 Jan 2005 10:16:34 +0100
Hi,
Daniel Stenberg wrote:
> On Tue, 18 Jan 2005, Kai Sommerfeld wrote:
>
>> as Curl_setopt (url.c) only supports CURLOPT_PROXY if
>> CURL_DISABLE_HTTP is not defined. IMHO, this is an inconsistency in
>> the curl implementation. I tried to fix it with the below patch,
>> which works fine for me.
>
>
> I can see how this would work, but I think I would rather have the fix
> the other way: the ftp_proxy (and other *_proxy variables) should not be
> used at all if HTTP is disabled.
>
> Thus, you wouldn't have to explicitly disable proxy when running HTTP
> disabled. I think that would be the most consistent approach.
>
> Attached here is my suggestion. It would be nice if you could verify
> that this works as intended. I'll commit it then.
>
Your suggested fix has one drawback when used in the OpenOffice.org
scenario: When building OpenOffice.org, you can either build curl as
part of it (and curl is then configured with --disable-http), or you can
use a curl already available on your system. In the latter case, it is
unknown to OpenOffice.org whether curl was configured with --enable-http
or --disable-http. However, when OpenOffice.org uses curl to access FTP
resources, it *never* wants curl to inspect any proxy environment
variables. Thus, OpenOffice.org always has to do
curl_easy_setopt(curl, CURLOPT_PROXY, "");
just in case curl was configured with --enable-http and the environment
variable ftp_proxy happens to be set to some value. Now, when the given
curl was configured with --disable-http, the above call will return
CURLE_FAILED_INIT. However, if curl was configured with --enable-http,
the above call should return CURLE_OK on success, and will, as far as I
understand it, return any other CURLcode (including CURLE_FAILED_INIT)
on failure. But that means that upon receiving CURLE_FAILED_INIT,
OpenOffice.org cannot tell whether the call to curl_easy_setopt was
either unnecessary (curl was configured with --disable-http) and failed
harmlessly, or was necessary (curl was configured with --enable-http)
and failed fatally.
Your suggested fix would thus only work for OpenOffice.org if a call
curl_easy_setopt(c, CURLOPT_PROXY, "");
with a valid argument c is guaranteed to only return CURLE_FAILED_INIT
in case curl was configured with --disable-http.
-Stephan
>
> ------------------------------------------------------------------------
>
> Index: lib/url.c
> ===================================================================
> RCS file: /cvsroot/curl/curl/lib/url.c,v
> retrieving revision 1.439
> diff -u -r1.439 url.c
> --- lib/url.c 16 Jan 2005 08:51:52 -0000 1.439
> +++ lib/url.c 18 Jan 2005 19:24:46 -0000
> @@ -2439,6 +2439,7 @@
> return CURLE_OUT_OF_MEMORY;
> }
>
> +#ifndef CURL_DISABLE_HTTP
> /*************************************************************
> * Detect what (if any) proxy to use
> *************************************************************/
> @@ -2603,6 +2604,7 @@
> if(no_proxy)
> free(no_proxy);
> } /* if not using proxy */
> +#endif
>
> /*************************************************************
> * No protocol part in URL was used, add it!
Received on 2005-01-19