1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_PRE_PROXY 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_HTTPPROXYTUNNEL (3) 9 - CURLOPT_PROXY (3) 10Protocol: 11 - All 12Added-in: 7.52.0 13--- 14 15# NAME 16 17CURLOPT_PRE_PROXY - pre-proxy host to use 18 19# SYNOPSIS 20 21~~~c 22#include <curl/curl.h> 23 24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PRE_PROXY, char *preproxy); 25~~~ 26 27# DESCRIPTION 28 29Set the *preproxy* to use for the upcoming request. The parameter should be a 30char * to a null-terminated string holding the hostname or dotted numerical IP 31address. A numerical IPv6 address must be written within [brackets]. 32 33To specify port number in this string, append :[port] to the end of the host 34name. The proxy's port number may optionally be specified with the separate 35option CURLOPT_PROXYPORT(3). If not specified, libcurl defaults to using 36port 1080 for proxies. 37 38A pre proxy is a SOCKS proxy that curl connects to before it connects to the 39HTTP(S) proxy specified in the CURLOPT_PROXY(3) option. The pre proxy 40can only be a SOCKS proxy. 41 42The pre proxy string should be prefixed with [scheme]:// to specify which kind 43of socks is used. Use socks4://, socks4a://, socks5:// or socks5h:// (the last 44one to enable socks5 and asking the proxy to do the resolving, also known as 45*CURLPROXY_SOCKS5_HOSTNAME* type) to request the specific SOCKS version to 46be used. Otherwise SOCKS4 is used as default. 47 48Setting the pre proxy string to "" (an empty string) explicitly disables the 49use of a pre proxy. 50 51When you set a hostname to use, do not assume that there is any particular 52single port number used widely for proxies. Specify it. 53 54The application does not have to keep the string around after setting this 55option. 56 57Using this option multiple times makes the last set string override the 58previous ones. Set it to NULL to disable its use again. 59 60# DEFAULT 61 62NULL 63 64# %PROTOCOLS% 65 66# EXAMPLE 67 68~~~c 69int main(void) 70{ 71 CURL *curl = curl_easy_init(); 72 if(curl) { 73 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/file.txt"); 74 curl_easy_setopt(curl, CURLOPT_PRE_PROXY, "socks4://socks-proxy:1080"); 75 curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80"); 76 curl_easy_perform(curl); 77 } 78} 79~~~ 80 81# %AVAILABILITY% 82 83# RETURN VALUE 84 85Returns CURLE_OK if proxies are supported, CURLE_UNKNOWN_OPTION if not, or 86CURLE_OUT_OF_MEMORY if there was insufficient heap space. 87