Steve Dell
Steve Dell

Reputation: 605

Preventing cURL from resolving host to IP

To save time I want to define what ip resolves from what host so curl doesn't have to waste time doing this itself (the IP will be static)

I just want confirmation from people more experienced with curl that the way I'm doing it will actually prevent curl from attempting to resolve the IP:

curl_easy_setopt(curl, CURLOPT_URL, "https://xxx.xxx.xxx.xxx");
struct curl_slist* chunk = NULL;
chunk = curl_slist_append(chunk,"Host: website.com"); //(the website doesn't respond correctly if the host is not set)
std::string curl_hosts = "website.com:443:xxx.xxx.xxx.xxx";
std::string curl_hosts80 = "website.com:80:xxx.xxx.xxx.xxx";
host = curl_slist_append(host,curl_hosts.c_str());
host = curl_slist_append(host,curl_hosts80.c_str());
curl_easy_setopt(curl, CURLOPT_RESOLVE, host);

Thanks.

Upvotes: 0

Views: 309

Answers (1)

Nir Alfasi
Nir Alfasi

Reputation: 53525

Add the host/ip to your /etc/hosts file

Upvotes: 1

Related Questions