The no_proxy (or NO_PROXY) env. variable is not used
properly by cURL when a port is specified in the URL.
Example : (Assume http servers are listening on ports
80 an 8888 on localhost)
$ export no_proxy=localhost
The following commands will succeed :
$ wget http://localhost/
$ lynx http://localhost/
$ curl http://localhost/
$ wget http://localhost:8888/
$ lynx http://localhost:8888/
While this one will fail :
$ curl http://localhost:8888/
It appears that curl does not properly handle (remove)
port numbers when checking host names against the
no_proxy variable.
This is pretty annoying as soon as you are behind a
proxy and run servers on the local network/host.
Anyway, curl is a very useful piece of software. Thanks
for making it exist.
Logged In: YES
user_id=1110
Thanks a lot for your report.
The following patch seems to fix the problem. It is also
already committed to CVS:
--- url.c 12 Apr 2002 10:03:59 -0000 1.201
+++ url.c 23 Apr 2002 13:28:55 -0000
@@ -1611,9 +1611,16 @@
nope=no_proxy?strtok_r(no_proxy, ", ",
&no_proxy_tok_buf):NULL;
while(nope) {
- if(strlen(nope) <= strlen(conn->name)) {
+ int namelen;
+ char *endptr = strchr(conn->name, ':');
+ if(endptr)
+ namelen=endptr-conn->name;
+ else
+ namelen=strlen(conn->name);
+
+ if(strlen(nope) <= namelen) {
char *checkn=
- conn->name + strlen(conn->name) - strlen(nope);
+ conn->name + namelen - strlen(nope);
if(strnequal(nope, checkn, strlen(nope))) {
/* no proxy for this host! */
break;
Logged In: YES
user_id=523821
Thanks for such a fast response, but as I used cURL quite a
lot this afternoon and swapping xterms with different
environments became boring, I also wrote a quick patch. As
far as I can see, this is pretty close to what you wrote:
*** curl-7.9.5/lib/url.c Fri Mar 1 00:31:23 2002
--- curl-7.9.5-erwan/lib/url.c Tue Apr 23 17:35:11 2002
*************** static CURLcode CreateConnection(struct
*** 1534,1545 ****
if(!no_proxy || !strequal("*", no_proxy)) {
/* NO_PROXY wasn't specified or it wasn't just an
asterisk */
char *nope;
nope=no_proxy?strtok_r(no_proxy, ", ",
&no_proxy_tok_buf):NULL;
while(nope) {
! if(strlen(nope) <= strlen(conn->name)) {
char *checkn=
! conn->name + strlen(conn->name) - strlen(nope);
if(strnequal(nope, checkn, strlen(nope))) {
/* no proxy for this host! */
break;
--- 1534,1550 ----
if(!no_proxy || !strequal("*", no_proxy)) {
/* NO_PROXY wasn't specified or it wasn't just an
asterisk */
char *nope;
+ /* find end of hostname if port number is specified */
+ char *colon=strchr(conn->name,':');
+ /* compute length of hostname once */
+ size_t
hostname_len=colon?colon-conn->name:strlen(conn->name);
nope=no_proxy?strtok_r(no_proxy, ", ",
&no_proxy_tok_buf):NULL;
while(nope) {
! if(strlen(nope) <= hostname_len) {
! /* check whether hostname and no_proxy token
match */
char *checkn=
! conn->name + hostname_len - strlen(nope);
if(strnequal(nope, checkn, strlen(nope))) {
/* no proxy for this host! */
break;
Logged In: YES
user_id=1110
Indeed almost a perfect mirror of my patch.
That also helps me conclude that the patch is what it takes
to make this work for you. (It worked in my local tests too.)
Again, thanks. Bug report already closed.