1CURLOPT_RESOLVE(3)         curl_easy_setopt options         CURLOPT_RESOLVE(3)
2
3
4

NAME

6       CURLOPT_RESOLVE - provide custom host name to IP address resolves
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RESOLVE,
12                                 struct curl_slist *hosts);
13

DESCRIPTION

15       Pass  a  pointer to a linked list of strings with host name resolve in‐
16       formation to use for requests with this handle. The linked list  should
17       be  a fully valid list of struct curl_slist structs properly filled in.
18       Use curl_slist_append(3) to create the list and  curl_slist_free_all(3)
19       to clean up an entire list.
20
21       Each resolve rule to add should be written using the format
22
23        [+]HOST:PORT:ADDRESS[,ADDRESS]
24
25       ...  where  HOST  is  the name libcurl will try to resolve, PORT is the
26       port number of the service where libcurl wants to connect to  the  HOST
27       and  ADDRESS is one or more numerical IP addresses. If you specify mul‐
28       tiple ip addresses they need to be separated by comma.  If  libcurl  is
29       built to support IPv6, each of the ADDRESS entries can of course be ei‐
30       ther IPv4 or IPv6 style addressing.
31
32       This option effectively pre-populates the DNS cache  with  entries  for
33       the  host+port pair so redirects and everything that operations against
34       the HOST+PORT will instead use your provided ADDRESS.
35
36       The optional leading "+" specifies that the new entry should  time-out.
37       Entries  added  without  the leading plus character will never time-out
38       whereas entries added with "+HOST:..." will time-out just like ordinary
39       DNS cache entries.
40
41       If the DNS cache already has an entry for the given host+port pair, the
42       new entry will override the former one.
43
44       An ADDRESS provided by this option will only be used if not  restricted
45       by the setting of CURLOPT_IPRESOLVE(3) to a different IP version.
46
47       To  remove names from the DNS cache again, to stop providing these fake
48       resolves, include a string in the linked list that uses the format
49
50         -HOST:PORT
51
52       The entry to remove must be prefixed with a dash, and the host name and
53       port number must exactly match what was added previously.
54

DEFAULT

56       NULL
57

PROTOCOLS

59       All
60

EXAMPLE

62       CURL *curl;
63       struct curl_slist *host = NULL;
64       host = curl_slist_append(NULL, "example.com:443:127.0.0.1");
65
66       curl = curl_easy_init();
67       if(curl) {
68         curl_easy_setopt(curl, CURLOPT_RESOLVE, host);
69         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
70
71         curl_easy_perform(curl);
72
73         /* always cleanup */
74         curl_easy_cleanup(curl);
75       }
76
77       curl_slist_free_all(host);
78

AVAILABILITY

80       Added in 7.21.3. Removal support added in 7.42.0.
81
82       Support  for  providing  the  ADDRESS  within  [brackets]  was added in
83       7.57.0.
84
85       Support for providing multiple IP addresses  per  entry  was  added  in
86       7.59.0.
87
88       Support  for  adding  non-permanent entries by using the "+" prefix was
89       added in 7.75.0.
90

RETURN VALUE

92       Returns CURLE_OK if the option is supported,  and  CURLE_UNKNOWN_OPTION
93       if not.
94

SEE ALSO

96       CURLOPT_IPRESOLVE(3),     CURLOPT_DNS_CACHE_TIMEOUT(3),    CURLOPT_CON‐
97       NECT_TO(3),
98
99
100
101libcurl 7.82.0                 January 10, 2022             CURLOPT_RESOLVE(3)
Impressum