Imported Upstream version 7.59.0
[platform/upstream/curl.git] / docs / libcurl / opts / CURLOPT_PRE_PROXY.3
1 .\" **************************************************************************
2 .\" *                                  _   _ ____  _
3 .\" *  Project                     ___| | | |  _ \| |
4 .\" *                             / __| | | | |_) | |
5 .\" *                            | (__| |_| |  _ <| |___
6 .\" *                             \___|\___/|_| \_\_____|
7 .\" *
8 .\" * Copyright (C) 1998 - 2017, 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.haxx.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_PRE_PROXY 3 "May 15, 2017" "libcurl 7.59.0" "curl_easy_setopt options"
24
25 .SH NAME
26 CURLOPT_PRE_PROXY \- set pre-proxy to use
27 .SH SYNOPSIS
28 #include <curl/curl.h>
29
30 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PRE_PROXY, char *preproxy);
31 .SH DESCRIPTION
32 Set the \fIpreproxy\fP to use for the upcoming request. The parameter
33 should be a char * to a zero terminated string holding the host name or dotted
34 numerical IP address. A numerical IPv6 address must be written within
35 [brackets].
36
37 To specify port number in this string, append :[port] to the end of the host
38 name. The proxy's port number may optionally be specified with the separate
39 option \fICURLOPT_PROXYPORT(3)\fP. If not specified, libcurl will default to
40 using port 1080 for proxies.
41
42 A pre proxy is a SOCKS proxy that curl connects to before it connects to the
43 HTTP(S) proxy specified in the \fICURLOPT_PROXY\fP option. The pre proxy can
44 only be a SOCKS proxy.
45
46 The pre proxy string should be prefixed with [scheme]:// to specify which kind
47 of socks is used. Use socks4://, socks4a://, socks5:// or socks5h:// (the last
48 one to enable socks5 and asking the proxy to do the resolving, also known as
49 \fICURLPROXY_SOCKS5_HOSTNAME\fP type) to request the specific SOCKS version to
50 be used. Otherwise SOCKS4 is used as default.
51
52 Setting the pre proxy string to "" (an empty string) will explicitly disable
53 the use of a pre proxy.
54
55 The application does not have to keep the string around after setting this
56 option.
57 .SH DEFAULT
58 Default is NULL, meaning no pre proxy is used.
59
60 When you set a host name to use, do not assume that there's any particular
61 single port number used widely for proxies. Specify it!
62 .SH PROTOCOLS
63 All except file://. Note that some protocols don't do very well over proxy.
64 .SH EXAMPLE
65 .nf
66 CURL *curl = curl_easy_init();
67 if(curl) {
68   curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/file.txt");
69   curl_easy_setopt(curl, CURLOPT_PREPROXY, "socks4://socks-proxy:1080");
70   curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80");
71   curl_easy_perform(curl);
72 }
73 .fi
74 .SH AVAILABILITY
75 Added in 7.52.0
76 .SH RETURN VALUE
77 Returns CURLE_OK if proxies are supported, CURLE_UNKNOWN_OPTION if not, or
78 CURLE_OUT_OF_MEMORY if there was insufficient heap space.
79 .SH "SEE ALSO"
80 .BR CURLOPT_PROXY "(3), " CURLOPT_HTTPPROXYTUNNEL "(3), "
81