1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_SUPPRESS_CONNECT_HEADERS
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_HEADER (3)
9  - CURLOPT_HTTPPROXYTUNNEL (3)
10  - CURLOPT_PROXY (3)
11Protocol:
12  - All
13Added-in: 7.54.0
14---
15
16# NAME
17
18CURLOPT_SUPPRESS_CONNECT_HEADERS - suppress proxy CONNECT response headers
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SUPPRESS_CONNECT_HEADERS, long onoff);
26~~~
27
28# DESCRIPTION
29
30When CURLOPT_HTTPPROXYTUNNEL(3) is used and a CONNECT request is made,
31suppress proxy CONNECT response headers from the user callback functions
32CURLOPT_HEADERFUNCTION(3) and CURLOPT_WRITEFUNCTION(3).
33
34Proxy CONNECT response headers can complicate header processing since it is
35essentially a separate set of headers. You can enable this option to suppress
36those headers.
37
38For example let's assume an HTTPS URL is to be retrieved via CONNECT. On
39success there would normally be two sets of headers, and each header line sent
40to the header function and/or the write function. The data given to the
41callbacks would look like this:
42
43~~~c
44HTTP/1.1 200 Connection established
45{headers}
46...
47
48HTTP/1.1 200 OK
49Content-Type: application/json
50{headers}
51...
52
53{body}
54...
55~~~
56
57However by enabling this option the CONNECT response headers are suppressed,
58so the data given to the callbacks would look like this:
59
60~~~c
61HTTP/1.1 200 OK
62Content-Type: application/json
63{headers}
64...
65
66{body}
67...
68~~~
69
70# DEFAULT
71
720
73
74# %PROTOCOLS%
75
76# EXAMPLE
77
78~~~c
79int main(void)
80{
81  CURL *curl = curl_easy_init();
82  if(curl) {
83    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
84
85    curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
86    curl_easy_setopt(curl, CURLOPT_PROXY, "http://foo:3128");
87    curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
88    curl_easy_setopt(curl, CURLOPT_SUPPRESS_CONNECT_HEADERS, 1L);
89
90    curl_easy_perform(curl);
91
92    /* always cleanup */
93    curl_easy_cleanup(curl);
94  }
95}
96~~~
97
98# %AVAILABILITY%
99
100# RETURN VALUE
101
102CURLE_OK or an error such as CURLE_UNKNOWN_OPTION.
103