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
16       information to use for requests  with  this  handle.  The  linked  list
17       should  be  a  fully  valid  list of struct curl_slist structs properly
18       filled  in.  Use  curl_slist_append(3)   to   create   the   list   and
19       curl_slist_free_all(3) to clean up an entire list.
20
21       Each  single  name  resolve  string  should be written using the format
22       HOST:PORT:ADDRESS[,ADDRESS]... where HOST is the name libcurl will  try
23       to  resolve, PORT is the port number of the service where libcurl wants
24       to connect to the  HOST  and  ADDRESS  is  one  or  more  numerical  IP
25       addresses.  If  you specify multiple ip addresses they need to be sepa‐
26       rated by comma. If libcurl is  built  to  support  IPv6,  each  of  the
27       ADDRESS entries can of course be either IPv4 or IPv6 style addressing.
28
29       This  option  effectively  pre-populates the DNS cache with entries for
30       the host+port pair so redirects and everything that operations  against
31       the  HOST+PORT  will  instead  use your provided ADDRESS. Addresses set
32       with CURLOPT_RESOLVE(3) will not time-out from the DNS cache like ordi‐
33       nary entries.
34
35       If  the  DNS  cache already have an entry for the given host+port pair,
36       then this entry will be removed and a new entry will be  created.  This
37       is  because  old entry may have have different addresses or be ordinary
38       entries with time-outs.
39
40       The provided ADDRESS set by this option  will  be  used  even  if  CUR‐
41       LOPT_IPRESOLVE(3) is set to make libcurl use another IP version.
42
43       Remove  names  from  the  DNS cache again, to stop providing these fake
44       resolves, by including a string in the linked list that uses the format
45       "-HOST:PORT".  The host name must be prefixed with a dash, and the host
46       name and port number must exactly match what was already  added  previ‐
47       ously.
48
49       Support  for  providing  the  ADDRESS  within  [brackets]  was added in
50       7.57.0.
51
52       Support for providing multiple IP addresses  per  entry  was  added  in
53       7.59.0.
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:80: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, "http://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

RETURN VALUE

83       Returns  CURLE_OK  if the option is supported, and CURLE_UNKNOWN_OPTION
84       if not.
85

SEE ALSO

87       CURLOPT_IPRESOLVE(3),    CURLOPT_DNS_CACHE_TIMEOUT(3),     CURLOPT_CON‐
88       NECT_TO(3),
89
90
91
92libcurl 7.61.1                   May 30, 2018               CURLOPT_RESOLVE(3)
Impressum