I'm having a bit of an odd issue with libcurl
- it's refusing to resolve a particular URL, returning the error message "Couldn't resolve host name." It has no issues resolving other hosts. I suspect the reason is that the URL which fails returns a 302 redirect, but I've set appropriate options for it to be followed.
The URL in question: http://servermods.cursecdn.com/files/922/48/worldedit-bukkit-6.1.3.jar
The relevant code:
CURL* curl;
FILE* data;
std::string url;
// ...
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
curl_easy_setopt(curl, CURLOPT_FILE, data);
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
CURLcode res = curl_easy_perform(curl);
libcurl
expects a char*
for CURLOPT_URL
. My code was passing a string
. This essentially causes the library to misinterpret the string and fail to resolve the host.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With