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