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