Imported Upstream version 7.50.2
[platform/upstream/curl.git] / docs / libcurl / opts / CURLOPT_CONNECT_TO.3
1 .\" **************************************************************************
2 .\" *                                  _   _ ____  _
3 .\" *  Project                     ___| | | |  _ \| |
4 .\" *                             / __| | | | |_) | |
5 .\" *                            | (__| |_| |  _ <| |___
6 .\" *                             \___|\___/|_| \_\_____|
7 .\" *
8 .\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
9 .\" *
10 .\" * This software is licensed as described in the file COPYING, which
11 .\" * you should have received as part of this distribution. The terms
12 .\" * are also available at http://curl.haxx.se/docs/copyright.html.
13 .\" *
14 .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 .\" * copies of the Software, and permit persons to whom the Software is
16 .\" * furnished to do so, under the terms of the COPYING file.
17 .\" *
18 .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 .\" * KIND, either express or implied.
20 .\" *
21 .\" **************************************************************************
22 .\"
23 .TH CURLOPT_CONNECT_TO 3 "10 April 2016" "libcurl 7.49.0" "curl_easy_setopt options"
24 .SH NAME
25 CURLOPT_CONNECT_TO \- Connect to a specific host and port instead of the URL's host and port
26 .SH SYNOPSIS
27 .nf
28 #include <curl/curl.h>
29
30 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECT_TO,
31                           struct curl_slist *connect_to);
32 .fi
33 .SH DESCRIPTION
34 Pass a pointer to a linked list of strings with "connect to" information to
35 use for establishing network connections with this handle. The linked list
36 should be a fully valid list of \fBstruct curl_slist\fP structs properly
37 filled in. Use \fIcurl_slist_append(3)\fP to create the list and
38 \fIcurl_slist_free_all(3)\fP to clean up an entire list.
39
40 Each single string should be written using the format
41 HOST:PORT:CONNECT-TO-HOST:CONNECT-TO-PORT where HOST is the host of the
42 request, PORT is the port of the request, CONNECT-TO-HOST is the host name to
43 connect to, and CONNECT-TO-PORT is the port to connect to.
44
45 The first string that matches the request's host and port is used.
46
47 Dotted numerical IP addresses are supported for HOST and CONNECT-TO-HOST.
48 A numerical IPv6 address must be written within [brackets].
49
50 Any of the four values may be empty. When the HOST or PORT is empty, the host
51 or port will always match (the request's host or port is ignored).
52 When CONNECT-TO-HOST or CONNECT-TO-PORT is empty, the "connect to" feature
53 will be disabled for the host or port, and the request's host or port will be
54 used to establish the network connection.
55
56 This option is suitable to direct the request at a specific server, e.g. at a
57 specific cluster node in a cluster of servers.
58
59 The "connect to" host and port are only used to establish the network
60 connection. They do NOT affect the host and port that are used for TLS/SSL
61 (e.g. SNI, certificate verification) or for the application protocols.
62
63 In contrast to \fICURLOPT_RESOLVE(3)\fP, the option
64 \fICURLOPT_CONNECT_TO(3)\fP does not pre-populate the DNS cache and therefore
65 it does not affect future transfers of other easy handles that have been added
66 to the same multi handle.
67
68 The "connect to" host and port are ignored if they are equal to the host and
69 the port in the request URL, because connecting to the host and the port in
70 the request URL is the default behavior.
71
72 If an HTTP proxy is used for a request having a special "connect to" host or
73 port, and the "connect to" host or port differs from the requests's host and
74 port, the HTTP proxy is automatically switched to tunnel mode for this
75 specific request. This is necessary because it is not possible to connect to a
76 specific host or port in normal (non-tunnel) mode.
77
78 When this option is passed to \fIcurl_easy_setopt(3)\fP, libcurl will not copy
79 the entire list so you \fBmust\fP keep it around until you no longer use this
80 \fIhandle\fP for a transfer before you call \fIcurl_slist_free_all(3)\fP on
81 the list.
82
83 .SH DEFAULT
84 NULL
85 .SH PROTOCOLS
86 All
87 .SH EXAMPLE
88 .nf
89 CURL *curl;
90 struct curl_slist *connect_to = NULL;
91 connect_to = curl_slist_append(NULL, "example.com::server1.example.com:");
92
93 curl = curl_easy_init();
94 if(curl) {
95   curl_easy_setopt(curl, CURLOPT_CONNECT_TO, connect_to);
96   curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
97
98   curl_easy_perform(curl);
99
100   /* always cleanup */
101   curl_easy_cleanup(curl);
102 }
103
104 curl_slist_free_all(connect_to);
105 .fi
106 .SH AVAILABILITY
107 Added in 7.49.0
108 .SH RETURN VALUE
109 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
110 .SH "SEE ALSO"
111 .BR CURLOPT_URL "(3), " CURLOPT_RESOLVE "(3), " CURLOPT_FOLLOWLOCATION "(3), " CURLOPT_HTTPPROXYTUNNEL  "(3), "