cURL / Mailing Lists / curl-library / Single Mail

curl-library

[PATCH] Consistent error return for bad proxy name when using c-ares

From: Mike Crowe <mac_at_mcrowe.com>
Date: Tue, 26 Jan 2010 13:04:10 +0000

This patch makes libcurl return CURLE_COULDNT_RESOLVE_PROXY when it is
the proxy that cannot be resolved when using c-ares. This matches the
behaviour when not using c-ares.

I copied the method from hostthre.c although I note that the string
format differs slightly - I can submit another patch for that if
required.

Thanks.

Mike.

diff -ru curl-7.19.7/lib/hostares.c curl-7.19.7.fixed/lib/hostares.c
--- curl-7.19.7.old/lib/hostares.c 2009-09-16 21:37:38.000000000 +0100
+++ curl-7.19.7/lib/hostares.c 2010-01-26 10:25:13.000000000 +0000
@@ -270,13 +270,26 @@
   if(!conn->async.dns) {
     /* a name was not resolved */
     if((timeout < 0) || (conn->async.status == ARES_ETIMEOUT)) {
- failf(data, "Resolving host timed out: %s", conn->host.dispname);
- rc = CURLE_COULDNT_RESOLVE_HOST;
+ if (conn->bits.httpproxy) {
+ failf(data, "Resolving proxy timed out: %s", conn->proxy.dispname);
+ rc = CURLE_COULDNT_RESOLVE_PROXY;
+ }
+ else {
+ failf(data, "Resolving host timed out: %s", conn->host.dispname);
+ rc = CURLE_COULDNT_RESOLVE_HOST;
+ }
     }
     else if(conn->async.done) {
- failf(data, "Could not resolve host: %s (%s)", conn->host.dispname,
- ares_strerror(conn->async.status));
- rc = CURLE_COULDNT_RESOLVE_HOST;
+ if (conn->bits.httpproxy) {
+ failf(data, "Could not resolve proxy: %s (%s)", conn->proxy.dispname,
+ ares_strerror(conn->async.status));
+ rc = CURLE_COULDNT_RESOLVE_PROXY;
+ }
+ else {
+ failf(data, "Could not resolve host: %s (%s)", conn->host.dispname,
+ ares_strerror(conn->async.status));
+ rc = CURLE_COULDNT_RESOLVE_HOST;
+ }
     }
     else
       rc = CURLE_OPERATION_TIMEDOUT;
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-01-26