CURLOPT_CONNECT_TO.3 4.6 KB

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