Q:

Curl returns all ok when bad ip supplied to CURLOPT_DNS_SERVERS

I've made a multithreaded (pthread) c++  program that is configured to use a list of custom dns.
In my tests I've used google's 8.8.8.8 for good ex, and some random ip like 113.65.123.138, 13.23.123.87 to test fail. But all goes the same in both cases, successfully.
Curl was built with C-ares support, and I've tested just to be sure:
curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
cout<<endl<<"Curl version: "<< data->version <<endl
    <<"AsyncDNS: "<<( data->features | CURL_VERSION_ASYNCHDNS ? "YES" : "NO"  ) <<endl;
//output: Curl version: 7.30.0 \n AsyncDNS: YES

The rest of the code:
curl_easy_setopt(curl, CURLOPT_DNS_SERVERS, thisThreadData->current_dns->dns_str.c_str()); 

curl_easy_setopt(curl, CURLOPT_DNS_USE_GLOBAL_CACHE,false); //thread safety 
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, CONNECT_TIMEOUT);    
curl_easy_setopt(curl, CURLOPT_TIMEOUT, CONNECTION_TIMEOUT);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 5);   
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_to_string);
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, &getUrlOutput->header);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &getUrlOutput->html);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "gzip,deflate");

status=curl_easy_perform(curl);

I've tested the random IPs (just in case I've stumbled on some valid DNS) :
$ host google.com 113.65.123.138
;; connection timed out; no servers could be reached
$ host google.com 13.23.123.87
;; connection timed out; no servers could be reached

What am I missing ?
Update
I've tried libcurl's latest version (7.33.0) and c-ares (1.10.0) and the same outcome.
Also if I supply a wrong domain for a url it returns CURLE_HTTP_RETURNED_ERROR (22) opposed to CURLE_COULDNT_RESOLVE_HOST (6).
Update 2
Forgot to mention that I used a HTML_PROXY for the connection, and it seems that was an important aspect, see answer.

A:

According to the curl forums, it's expected behavior as the dns is handled by the proxy.

When I am using a proxy, how do I (or can I) control 
    whether the target url is resolved locally or by the proxy? I have 
    conditions where I need both choices.  

With HTTP-Proxy the client (curl) hands over the full URL to the proxy and the proxy will  resolve the hostname .
  If you really want to do it client-side, then you need to
  first resolve the  name and then "re-arrange" the URL to use IP
  numericals only and set the Host:  header to contain the host name you
  resolved.

In my case when the proxy's DNS finds an error it returns a html formated error page with the message "host not found", html_status 503, that's why curl passed dns checks and said the domain is ok, but failed with CURLE_HTTP_RETURNED_ERROR.

