xref: /aosp_15_r20/external/curl/docs/libcurl/opts/CURLOPT_HTTPPROXYTUNNEL.md (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker---
2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al.
3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl
4*6236dae4SAndroid Build Coastguard WorkerTitle: CURLOPT_HTTPPROXYTUNNEL
5*6236dae4SAndroid Build Coastguard WorkerSection: 3
6*6236dae4SAndroid Build Coastguard WorkerSource: libcurl
7*6236dae4SAndroid Build Coastguard WorkerProtocol:
8*6236dae4SAndroid Build Coastguard Worker  - All
9*6236dae4SAndroid Build Coastguard WorkerSee-also:
10*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_PROXY (3)
11*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_PROXYPORT (3)
12*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_PROXYTYPE (3)
13*6236dae4SAndroid Build Coastguard WorkerAdded-in: 7.3
14*6236dae4SAndroid Build Coastguard Worker---
15*6236dae4SAndroid Build Coastguard Worker
16*6236dae4SAndroid Build Coastguard Worker# NAME
17*6236dae4SAndroid Build Coastguard Worker
18*6236dae4SAndroid Build Coastguard WorkerCURLOPT_HTTPPROXYTUNNEL - tunnel through HTTP proxy
19*6236dae4SAndroid Build Coastguard Worker
20*6236dae4SAndroid Build Coastguard Worker# SYNOPSIS
21*6236dae4SAndroid Build Coastguard Worker
22*6236dae4SAndroid Build Coastguard Worker~~~c
23*6236dae4SAndroid Build Coastguard Worker#include <curl/curl.h>
24*6236dae4SAndroid Build Coastguard Worker
25*6236dae4SAndroid Build Coastguard WorkerCURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPPROXYTUNNEL, long tunnel);
26*6236dae4SAndroid Build Coastguard Worker~~~
27*6236dae4SAndroid Build Coastguard Worker
28*6236dae4SAndroid Build Coastguard Worker# DESCRIPTION
29*6236dae4SAndroid Build Coastguard Worker
30*6236dae4SAndroid Build Coastguard WorkerSet the **tunnel** parameter to 1L to make libcurl tunnel all operations
31*6236dae4SAndroid Build Coastguard Workerthrough the HTTP proxy (set with CURLOPT_PROXY(3)). There is a big
32*6236dae4SAndroid Build Coastguard Workerdifference between using a proxy and to tunnel through it.
33*6236dae4SAndroid Build Coastguard Worker
34*6236dae4SAndroid Build Coastguard WorkerTunneling means that an HTTP CONNECT request is sent to the proxy, asking it
35*6236dae4SAndroid Build Coastguard Workerto connect to a remote host on a specific port number and then the traffic is
36*6236dae4SAndroid Build Coastguard Workerjust passed through the proxy. Proxies tend to white-list specific port numbers
37*6236dae4SAndroid Build Coastguard Workerit allows CONNECT requests to and often only port 80 and 443 are allowed.
38*6236dae4SAndroid Build Coastguard Worker
39*6236dae4SAndroid Build Coastguard WorkerTo suppress proxy CONNECT response headers from user callbacks use
40*6236dae4SAndroid Build Coastguard WorkerCURLOPT_SUPPRESS_CONNECT_HEADERS(3).
41*6236dae4SAndroid Build Coastguard Worker
42*6236dae4SAndroid Build Coastguard WorkerHTTP proxies can generally only speak HTTP (for obvious reasons), which makes
43*6236dae4SAndroid Build Coastguard Workerlibcurl convert non-HTTP requests to HTTP when using an HTTP proxy without
44*6236dae4SAndroid Build Coastguard Workerthis tunnel option set. For example, asking for an FTP URL and specifying an
45*6236dae4SAndroid Build Coastguard WorkerHTTP proxy makes libcurl send an FTP URL in an HTTP GET request to the
46*6236dae4SAndroid Build Coastguard Workerproxy. By instead tunneling through the proxy, you avoid that conversion (that
47*6236dae4SAndroid Build Coastguard Workerrarely works through the proxy anyway).
48*6236dae4SAndroid Build Coastguard Worker
49*6236dae4SAndroid Build Coastguard Worker# DEFAULT
50*6236dae4SAndroid Build Coastguard Worker
51*6236dae4SAndroid Build Coastguard Worker0
52*6236dae4SAndroid Build Coastguard Worker
53*6236dae4SAndroid Build Coastguard Worker# %PROTOCOLS%
54*6236dae4SAndroid Build Coastguard Worker
55*6236dae4SAndroid Build Coastguard Worker# EXAMPLE
56*6236dae4SAndroid Build Coastguard Worker
57*6236dae4SAndroid Build Coastguard Worker~~~c
58*6236dae4SAndroid Build Coastguard Workerint main(void)
59*6236dae4SAndroid Build Coastguard Worker{
60*6236dae4SAndroid Build Coastguard Worker  CURL *curl = curl_easy_init();
61*6236dae4SAndroid Build Coastguard Worker  if(curl) {
62*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt");
63*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1:80");
64*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
65*6236dae4SAndroid Build Coastguard Worker    curl_easy_perform(curl);
66*6236dae4SAndroid Build Coastguard Worker  }
67*6236dae4SAndroid Build Coastguard Worker}
68*6236dae4SAndroid Build Coastguard Worker~~~
69*6236dae4SAndroid Build Coastguard Worker
70*6236dae4SAndroid Build Coastguard Worker# %AVAILABILITY%
71*6236dae4SAndroid Build Coastguard Worker
72*6236dae4SAndroid Build Coastguard Worker# RETURN VALUE
73*6236dae4SAndroid Build Coastguard Worker
74*6236dae4SAndroid Build Coastguard WorkerReturns CURLE_OK
75