CURLOPT_SU...CT_HEADERS(3)

πŸ’… CURLOPT_SUPPRESS_CONNECT_HEADERS πŸ’…

okay bestie so this is a page straight out of the Library Functions Manual for libcurl, and it's about CURLOPT_SUPPRESS_CONNECT_HEADERS β€” literally the option that tells curl to stop showing you the proxy's extra headers. it's giving "quiet luxury" for your callback functions. iykyk πŸŽ€


✨ NAME ✨

CURLOPT_SUPPRESS_CONNECT_HEADERS β€” suppress proxy CONNECT response headers, periodt. πŸ’…


🌸 SYNOPSIS 🌸

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SUPPRESS_CONNECT_HEADERS, long onoff);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea πŸ«– β€” when CURLOPT_HTTPPROXYTUNNEL(3) is in play and a CONNECT request happens, this option suppresses the proxy CONNECT response headers so they never reach your user callback functions CURLOPT_HEADERFUNCTION(3) and CURLOPT_WRITEFUNCTION(3). no cap.

why would you want that? because proxy CONNECT response headers can lowkey complicate your header processing β€” it's basically a whole separate set of headers just chilling there. you can enable this option to suppress them. slay. ✨

okay so for example, let's say you're retrieving an HTTPS URL via CONNECT. on success there would normally be two sets of headers, and every single header line gets sent to the header function and/or the write function. the data your callbacks receive would look like this:

HTTP/1.1 200 Connection established
{headers}
...

HTTP/1.1 200 OK
Content-Type: application/json
{headers}
...

{body}
...

but β€” plot twist 🎬 β€” by enabling this option the CONNECT response headers get suppressed, so the data given to the callbacks would look like this instead:

HTTP/1.1 200 OK
Content-Type: application/json
{headers}
...

{body}
...

so much cleaner. the way that second block ate and left no crumbs. πŸ‘‘


πŸ’– DEFAULT πŸ’–

0

(the extra headers are not suppressed unless you say so, bestie 🫢)


🌈 PROTOCOLS 🌈

this functionality affects all supported protocols. all of them. every single one. iconic behaviour honestly. ⭐


πŸ“ EXAMPLE πŸ“

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");

    curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
    curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy.example:3128");
    curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
    curl_easy_setopt(curl, CURLOPT_SUPPRESS_CONNECT_HEADERS, 1L);

    curl_easy_perform(curl);

    /* always cleanup */
    curl_easy_cleanup(curl);
  }
}

look at her go πŸ˜­πŸ’œ


🧚 AVAILABILITY 🧚

added in curl 7.54.0 β€” so if you're on something ancient, that's a vibe check you're gonna fail πŸ™ˆ


πŸ”₯ RETURN VALUE πŸ”₯

CURLE_OK or an error such as CURLE_UNKNOWN_OPTION.

so basically: success, or a lil error telling you things went sideways πŸ’€


πŸ‘‘ SEE ALSO πŸ‘‘

go read those next, bestie, they're all part of the same little friend group 🫢


and that's the whole page, mwah πŸ’‹ β€” brought to you by libcurl, dated 2026-10-12, straight from the Library Functions Manual. go forth and suppress those headers, main character. βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from