CURLOPT_HT...R_DECODING(3)

πŸ’… CURLOPT_HTTP_TRANSFER_DECODING(3) πŸ’…

okay so bestie, this is a page from the Library Functions Manual, and it's all about CURLOPT_HTTP_TRANSFER_DECODING β€” the HTTP transfer decoding control. yes that's a mouthful, we're gonna get through it together 🫢


✨ NAME ✨

CURLOPT_HTTP_TRANSFER_DECODING β€” HTTP transfer decoding control


🌸 SYNOPSIS 🌸

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTP_TRANSFER_DECODING,
                         long enabled);

πŸ¦‹ DESCRIPTION πŸ¦‹

so you pass a long in here and it tells libcurl how to act on transfer decoding. that's the whole vibe check:

  • if you set it to zero, transfer decoding is disabled πŸ™ˆ
  • if you set it to 1, it's enabled β€” and yes, that's the default πŸ’–

and like, lowkey the important bit: libcurl does chunked transfer decoding by default unless you set this option to zero. so if you never touch this, chunked decoding is happening. periodt ✨


πŸŽ€ DEFAULT πŸŽ€

1

(one. enabled. the icon it is πŸ‘‘)


🌈 PROTOCOLS 🌈

this functionality affects http only β€” that's it, that's the list πŸ’…


⭐ EXAMPLE ⭐

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
    curl_easy_setopt(curl, CURLOPT_HTTP_TRANSFER_DECODING, 0L);
    result = curl_easy_perform(curl);
  }
}

not me setting it to 0L in the example β€” look at us turning transfer decoding off on purpose, main character energy fr fr πŸ”₯


🧚 AVAILABILITY 🧚

Added in curl 7.16.2 β€” a vintage. she's been around πŸ’œ


πŸ’€ RETURN VALUE πŸ’€

curl_easy_setopt(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK 😌 β€” and non-zero means an error occurred 😭, see libcurl-errors(3) for the full tea.


πŸ“ SEE ALSO πŸ“

go read those next bestie, iykyk πŸ¦‹


mwah πŸ’‹ that's the whole page β€” brought to you by libcurl, dated 2026-10-12. go forth and decode your transfers responsibly βœ¨πŸ‘‘

πŸ“¦ where this page comes from