1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_HTTPPROXYTUNNEL 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_PROXY (3) 9 - CURLOPT_PROXYPORT (3) 10 - CURLOPT_PROXYTYPE (3) 11--- 12 13# NAME 14 15CURLOPT_HTTPPROXYTUNNEL - tunnel through HTTP proxy 16 17# SYNOPSIS 18 19~~~c 20#include <curl/curl.h> 21 22CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPPROXYTUNNEL, long tunnel); 23~~~ 24 25# DESCRIPTION 26 27Set the **tunnel** parameter to 1L to make libcurl tunnel all operations 28through the HTTP proxy (set with CURLOPT_PROXY(3)). There is a big 29difference between using a proxy and to tunnel through it. 30 31Tunneling means that an HTTP CONNECT request is sent to the proxy, asking it 32to connect to a remote host on a specific port number and then the traffic is 33just passed through the proxy. Proxies tend to white-list specific port numbers 34it allows CONNECT requests to and often only port 80 and 443 are allowed. 35 36To suppress proxy CONNECT response headers from user callbacks use 37CURLOPT_SUPPRESS_CONNECT_HEADERS(3). 38 39HTTP proxies can generally only speak HTTP (for obvious reasons), which makes 40libcurl convert non-HTTP requests to HTTP when using an HTTP proxy without 41this tunnel option set. For example, asking for an FTP URL and specifying an 42HTTP proxy makes libcurl send an FTP URL in an HTTP GET request to the 43proxy. By instead tunneling through the proxy, you avoid that conversion (that 44rarely works through the proxy anyway). 45 46# DEFAULT 47 480 49 50# PROTOCOLS 51 52All network protocols 53 54# EXAMPLE 55 56~~~c 57int main(void) 58{ 59 CURL *curl = curl_easy_init(); 60 if(curl) { 61 curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt"); 62 curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1:80"); 63 curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L); 64 curl_easy_perform(curl); 65 } 66} 67~~~ 68 69# AVAILABILITY 70 71Always 72 73# RETURN VALUE 74 75Returns CURLE_OK 76