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