CURLOPT_RESOLVE is not working correctly? #8109
-
Hello, I am trying to use the CURLOPT_RESOLVE option to request a direct IP address. The documentation says that: https://curl.se/libcurl/c/CURLOPT_RESOLVE.html
and an example is given:
However - this does not work as described in the documentation. port number added at - curl_slist_append(NULL, "example.com:80:127.0.0.1") - not working. I can specify the port number at least 666, Is this a bug in the documentation or a bug in libcurl? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
On Tue, Dec 07, 2021 at 12:41:53AM -0800, Lator wrote:
port number added at - curl_slist_append(NULL, "example.com:80:127.0.0.1") -
not working.
What do you mean by "not working"?
But libcurl, it will connect ONLY by the port number specified in -
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com") - that is, the
prefix "http" or "https" - only 80 и 443.
The resolved address specified above is for port 80, but this URL specifies
port 443 (implicitly). So, the cache won't be used for this request.
|
Beta Was this translation helpful? Give feedback.
-
You've understood it backwards. |
Beta Was this translation helpful? Give feedback.
-
You ONLY need thi if for some reason YOU decide that "example.com:666" should map to "140.82.121.4". Otherwise curl will simply query the DNS for the IP of "example.com". |
Beta Was this translation helpful? Give feedback.
You've understood it backwards.
When you say "example.com:666:140.82.121.4" it means to curl "whenever you want to connect to 'example.com' on port 666, use '140.82.121.4' as the IP". It does not magically change the default port of http/s to 666.
So this entry will only have an effect if you say
curl_easy_setopt (curl, CURLOPT_URL, "https://example.com:666");