cURL / Mailing Lists / curl-library / Single Mail

curl-library

no_proxy is being ignored

From: Robert Foreman <robert.foreman_at_rd.bbc.co.uk>
Date: Wed, 20 Dec 2006 16:59:30 +0000

Hello,

I'm having a problem concerning the http_proxy and no_proxy environment
variables.

First off, the basic details (I've had to <snip> a few things from here):

-bash-3.00$ uname -a
Linux <snip> 2.6.11-prep #29 Fri Nov 4 13:04:57 GMT 2005 i686 i686 i386
GNU/Linux
-bash-3.00$ curl -V
curl 7.16.0 (i686-pc-linux-gnu) libcurl/7.16.0 OpenSSL/0.9.7a
zlib/1.2.1.2 libidn/0.5.6
Protocols: tftp ftp telnet dict ldap http file https ftps
Features: Debug IDN IPv6 Largefile NTLM SSL libz
-bash-3.00$ echo $http_proxy
http://www-cache:80
-bash-3.00$ echo $no_proxy
127.0.0.1,<snip>

I've built libcurl with debug symbols.

My program correctly makes GET, PUT and POST requests for URLs that
should not be proxied. It then makes a GET request to an URL that should
be proxied.

After this, all connections go through the proxy, whether they should or
not. I get some debug output that looks like this:

== Info: Examining connection #0 for reuse
== Info: Examining connection #1 for reuse
== Info: Connection #1 seems to be dead!
== Info: Closing connection #1
== Info: About to connect() to proxy www-cache port 80 (#1)
== Info: Trying 132.185.128.105... == Info: connected
== Info: Connected to www-cache (132.185.128.105) port 80 (#1)
=> Send header, 192 bytes (0xc0)
0000: GET <a URL that shouldn't go through the proxy> HTTP/1.1
<snip headers>
00a0: Proxy-Connection: Keep-Alive
<snip headers>
== Info: HTTP/1.0 proxy connection set to keep alive!
<= Recv header, 30 bytes (0x1e)
0000: Proxy-Connection: keep-alive
<= Recv data, 2331 bytes (0x91b)

My program does not set CURLOPT_PROXY.

I've had a look at lib/url.c and stepped through in the debugger and
noticed a couple of points:

1) Until the first connection to go through the proxy, every connection
reaches line 2841, enters the if-clause as data->change.proxy is 0, and
correctly uses the no_proxy environment variable.
2) When a connection goes through the proxy, it reaches line 2937 and
executes data->change.proxy = proxy;
3) After this has happened, any subsequent connection will reach line
2841 but the if(!data->change.proxy) condition is now false because
data->change.proxy contains the name of the proxy.
4) The only way (that I can see) that data->change.proxy can be changed
is by setting CURLOPT_PROXY at line 1099 or at line 2937. However, once
the proxy is set, line 2937 cannot be reached.

I'm not very familiar with the libcurl source code, so I may have made a
mistake in there somewhere, but I hope that's enough for someone to
help. If I manage to fix the problem myself, I'll post back with a patch
(if it's curl's fault) or what I did wrong (if it's my fault ;-P )

Yours,

Rob Foreman
BBC Research
Received on 2006-12-20