Imported Upstream version 7.48.0
[platform/upstream/curl.git] / docs / libcurl / opts / CURLOPT_RESOLVE.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2  "http://www.w3.org/TR/html4/loose.dtd">
3 <html><head>
4 <title>CURLOPT_RESOLVE man page</title>
5 <meta name="generator" content="roffit">
6 <STYLE type="text/css">
7 pre {
8   overflow: auto;
9   margin: 0;
10 }
11
12 P.level0, pre.level0 {
13  padding-left: 2em;
14 }
15
16 P.level1, pre.level1 {
17  padding-left: 4em;
18 }
19
20 P.level2, pre.level2 {
21  padding-left: 6em;
22 }
23
24 span.emphasis {
25  font-style: italic;
26 }
27
28 span.bold {
29  font-weight: bold;
30 }
31
32 span.manpage {
33  font-weight: bold;
34 }
35
36 h2.nroffsh {
37  background-color: #e0e0e0;
38 }
39
40 span.nroffip {
41  font-weight: bold;
42  font-size: 120%;
43  font-family: monospace;
44 }
45
46 p.roffit {
47  text-align: center;
48  font-size: 80%;
49 }
50 </STYLE>
51 </head><body>
52
53 <p class="level0"><a name="NAME"></a><h2 class="nroffsh">NAME</h2>
54 <p class="level0">CURLOPT_RESOLVE - provide custom host name to IP address resolves <a name="SYNOPSIS"></a><h2 class="nroffsh">SYNOPSIS</h2>
55 <p class="level0"><pre class="level0">
56 &#35;include &lt;curl/curl.h&gt;
57 &nbsp;
58 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RESOLVE,
59 &nbsp;                         struct curl_slist *hosts);
60 </pre>
61 <a name="DESCRIPTION"></a><h2 class="nroffsh">DESCRIPTION</h2>
62 <p class="level0">Pass a pointer to a linked list of strings with host name resolve information to use for requests with this handle. The linked list should be a fully valid list of <span Class="bold">struct curl_slist</span> structs properly filled in. Use <span Class="emphasis">curl_slist_append(3)</span> to create the list and <span Class="emphasis">curl_slist_free_all(3)</span> to clean up an entire list. 
63 <p class="level0">Each single name resolve string should be written using the format HOST:PORT:ADDRESS where HOST is the name libcurl will try to resolve, PORT is the port number of the service where libcurl wants to connect to the HOST and ADDRESS is the numerical IP address. If libcurl is built to support IPv6, ADDRESS can of course be either IPv4 or IPv6 style addressing. 
64 <p class="level0">This option effectively pre-populates the DNS cache with entries for the host+port pair so redirects and everything that operations against the HOST+PORT will instead use your provided ADDRESS. Addresses set with <span Class="emphasis">CURL_RESOLVE</span> will not time-out from the DNS cache like ordinary entries. 
65 <p class="level0">Remove names from the DNS cache again, to stop providing these fake resolves, by including a string in the linked list that uses the format "-HOST:PORT". The host name must be prefixed with a dash, and the host name and port number must exactly match what was already added previously. (Added in 7.42.0) <a name="DEFAULT"></a><h2 class="nroffsh">DEFAULT</h2>
66 <p class="level0">NULL <a name="PROTOCOLS"></a><h2 class="nroffsh">PROTOCOLS</h2>
67 <p class="level0">All <a name="EXAMPLE"></a><h2 class="nroffsh">EXAMPLE</h2>
68 <p class="level0"><pre class="level0">
69 CURL *curl;
70 struct curl_slist *host = NULL;
71 host = curl_slist_append(NULL, "example.com:80:127.0.0.1");
72 &nbsp;
73 curl = curl_easy_init();
74 if(curl) {
75 &nbsp; curl_easy_setopt(curl, CURLOPT_RESOLVE, host);
76 &nbsp; curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
77 &nbsp; res = curl_easy_perform(curl);
78 &nbsp;
79 &nbsp; /* always cleanup */
80 &nbsp; curl_easy_cleanup(curl);
81 }
82 &nbsp;
83 curl_slist_free_all(host);
84 </pre>
85
86 <p class="level0"><a name="AVAILABILITY"></a><h2 class="nroffsh">AVAILABILITY</h2>
87 <p class="level0">Added in 7.21.3. Removal support added in 7.42.0. <a name="RETURN"></a><h2 class="nroffsh">RETURN VALUE</h2>
88 <p class="level0">Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. <a name="SEE"></a><h2 class="nroffsh">SEE ALSO</h2>
89 <p class="level0"><a Class="manpage" href="./CURLOPT_IPRESOLVE.html">CURLOPT_IPRESOLVE</a>, <a Class="manpage" href="./CURLOPT_DNS_CACHE_TIMEOUT.html">CURLOPT_DNS_CACHE_TIMEOUT</a><p class="roffit">
90  This HTML page was made with <a href="http://daniel.haxx.se/projects/roffit/">roffit</a>.
91 </body></html>