2
0

CURLOPT_CONNECT_TO.3 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 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 https://curl.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. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH CURLOPT_CONNECT_TO 3 "10 April 2016" libcurl libcurl
  26. .SH NAME
  27. CURLOPT_CONNECT_TO \- connect to a specific host and port instead of the URL's host and port
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECT_TO,
  32. struct curl_slist *connect_to);
  33. .fi
  34. .SH DESCRIPTION
  35. Pass a pointer to a linked list of strings with "connect to" information to
  36. use for establishing network connections with this handle. The linked list
  37. should be a fully valid list of \fBstruct curl_slist\fP structs properly
  38. filled in. Use \fIcurl_slist_append(3)\fP to create the list and
  39. \fIcurl_slist_free_all(3)\fP to clean up an entire list.
  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. The first string that matches the request's host and port is used.
  45. Dotted numerical IP addresses are supported for HOST and CONNECT-TO-HOST.
  46. A numerical IPv6 address must be written within [brackets].
  47. Any of the four values may be empty. When the HOST or PORT is empty, the host
  48. or port will always match (the request's host or port is ignored).
  49. When CONNECT-TO-HOST or CONNECT-TO-PORT is empty, the "connect to" feature
  50. will be disabled for the host or port, and the request's host or port will be
  51. used to establish the network connection.
  52. This option is suitable to direct the request at a specific server, e.g. at a
  53. specific cluster node in a cluster of servers.
  54. The "connect to" host and port are only used to establish the network
  55. connection. They do NOT affect the host and port that are used for TLS/SSL
  56. (e.g. SNI, certificate verification) or for the application protocols.
  57. In contrast to \fICURLOPT_RESOLVE(3)\fP, the option
  58. \fICURLOPT_CONNECT_TO(3)\fP does not pre-populate the DNS cache and therefore
  59. it does not affect future transfers of other easy handles that have been added
  60. to the same multi handle.
  61. The "connect to" host and port are ignored if they are equal to the host and
  62. the port in the request URL, because connecting to the host and the port in
  63. the request URL is the default behavior.
  64. If an HTTP proxy is used for a request having a special "connect to" host or
  65. port, and the "connect to" host or port differs from the request's host and
  66. port, the HTTP proxy is automatically switched to tunnel mode for this
  67. specific request. This is necessary because it is not possible to connect to a
  68. specific host or port in normal (non-tunnel) mode.
  69. When this option is passed to \fIcurl_easy_setopt(3)\fP, libcurl will not copy
  70. the entire list so you \fBmust\fP keep it around until you no longer use this
  71. \fIhandle\fP for a transfer before you call \fIcurl_slist_free_all(3)\fP on
  72. the list.
  73. .SH DEFAULT
  74. NULL
  75. .SH PROTOCOLS
  76. All
  77. .SH EXAMPLE
  78. .nf
  79. CURL *curl;
  80. struct curl_slist *connect_to = NULL;
  81. connect_to = curl_slist_append(NULL, "example.com::server1.example.com:");
  82. curl = curl_easy_init();
  83. if(curl) {
  84. curl_easy_setopt(curl, CURLOPT_CONNECT_TO, connect_to);
  85. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  86. curl_easy_perform(curl);
  87. /* always cleanup */
  88. curl_easy_cleanup(curl);
  89. }
  90. curl_slist_free_all(connect_to);
  91. .fi
  92. .SH AVAILABILITY
  93. Added in 7.49.0
  94. .SH RETURN VALUE
  95. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  96. .SH "SEE ALSO"
  97. .BR CURLOPT_URL "(3), " CURLOPT_RESOLVE "(3), " CURLOPT_FOLLOWLOCATION "(3), " CURLOPT_HTTPPROXYTUNNEL "(3), "