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