cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Can't resolve host

From: Ray Satiro via curl-library <curl-library_at_cool.haxx.se>
Date: Mon, 09 Mar 2015 16:32:09 -0400

On 3/5/2015 7:52 PM, Mathieu Fregeau wrote:
> library version: curl 7.41.0
> compiler: c++, mingw32 (gcc 4.8)
>
> I can't resolve my request when at the office computer, while it works well at home. I suspect something about firewall, but I can browse on the same url via a browser (firefox and ie). Is there a way to have curl use the same exact settings of the current browser? such that I can use the same channels or firewall bypass?
>
> Here are my request settings:
>
> curl_easy_setopt(curl, CURLOPT_URL, url);
> curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);//follow redirection
> curl_easy_setopt(curl, CURLOPT_REFERER, url);
> curl_easy_setopt(curl, CURLOPT_HEADER, 0L);
> curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);//no progress
> curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);//1=verbose, 0=non verbose
> curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
> curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER);
> curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS | CURLPROTO_FILE | CURLPROTO_SCP);
> curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912 Safari/535.7 Firefox/3.5.16");
> curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1L);
> curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);//report failure for http code > 400
> curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteFunction);//function to keep response
> curl_easy_setopt(curl, CURLOPT_WRITEDATA, &body);// keep response in variable
>
> res = curl_easy_perform(curl);
>
> like I said it works from my home computer but just not at work.

Go into Internet Options > Connections > LAN settings and see if you
have a proxy server. You can use CURLOPT_PROXY to set the proxy [1].
There isn't functionality in libcurl to get that proxy configuration
automatically, though you can find some code that shows how to do that
at [2].

Also I'm reminded of a similar "can't resolve host" in windows question
on the mailing list a week ago where the user had only partially
initialized libcurl [3]. Absent that try my suggestions from that thread
[4].

[1]: http://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html
[2]:
http://stackoverflow.com/questions/202547/how-do-i-find-out-the-browsers-proxy-settings
[3]: http://curl.haxx.se/mail/lib-2015-03/0061.html
[4]: http://curl.haxx.se/mail/lib-2015-03/0046.html

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-03-09