CURLOPT_PRE_PROXY.3 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. .\" generated by cd2nroff 0.1 from CURLOPT_PRE_PROXY.md
  2. .TH CURLOPT_PRE_PROXY 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_PRE_PROXY \- pre\-proxy host to use
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PRE_PROXY, char *preproxy);
  9. .fi
  10. .SH DESCRIPTION
  11. Set the \fIpreproxy\fP to use for the upcoming request. The parameter should be a
  12. char * to a null\-terminated string holding the hostname or dotted numerical IP
  13. address. A numerical IPv6 address must be written within [brackets].
  14. To specify port number in this string, append :[port] to the end of the host
  15. name. The proxy\(aqs port number may optionally be specified with the separate
  16. option \fICURLOPT_PROXYPORT(3)\fP. If not specified, libcurl defaults to using
  17. port 1080 for proxies.
  18. A pre proxy is a SOCKS proxy that curl connects to before it connects to the
  19. HTTP(S) proxy specified in the \fICURLOPT_PROXY(3)\fP option. The pre proxy
  20. can only be a SOCKS proxy.
  21. The pre proxy string should be prefixed with [scheme]:// to specify which kind
  22. of socks is used. Use socks4://, socks4a://, socks5:// or socks5h:// (the last
  23. one to enable socks5 and asking the proxy to do the resolving, also known as
  24. \fICURLPROXY_SOCKS5_HOSTNAME\fP type) to request the specific SOCKS version to
  25. be used. Otherwise SOCKS4 is used as default.
  26. Setting the pre proxy string to "" (an empty string) explicitly disables the
  27. use of a pre proxy.
  28. When you set a hostname to use, do not assume that there is any particular
  29. single port number used widely for proxies. Specify it.
  30. The application does not have to keep the string around after setting this
  31. option.
  32. .SH DEFAULT
  33. NULL
  34. .SH PROTOCOLS
  35. This functionality affects all supported protocols
  36. .SH EXAMPLE
  37. .nf
  38. int main(void)
  39. {
  40. CURL *curl = curl_easy_init();
  41. if(curl) {
  42. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/file.txt");
  43. curl_easy_setopt(curl, CURLOPT_PRE_PROXY, "socks4://socks-proxy:1080");
  44. curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80");
  45. curl_easy_perform(curl);
  46. }
  47. }
  48. .fi
  49. .SH AVAILABILITY
  50. Added in curl 7.52.0
  51. .SH RETURN VALUE
  52. Returns CURLE_OK if proxies are supported, CURLE_UNKNOWN_OPTION if not, or
  53. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  54. .SH SEE ALSO
  55. .BR CURLOPT_HTTPPROXYTUNNEL (3),
  56. .BR CURLOPT_PROXY (3)