GNURLOPT_T...R_ENCODING(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

✨ GNURLOPT_T...R_ENCODING(3) ✨

okay so bestie, real talk β€” this whole page lives in the curl_easy_setopt options manual, and the star of the show is CURLOPT_TRANSFER_ENCODING. yes the header is squished like GNURLOPT_T...R_ENCODING(3), no that's not a typo, that's just how the terminal eats it πŸ’…


πŸŽ€ NAME πŸŽ€

CURLOPT_TRANSFER_ENCODING β€” the one where you ask for HTTP Transfer Encoding πŸ¦‹


🌸 SYNOPSIS 🌸

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TRANSFER_ENCODING, long
enable);

πŸ’– DESCRIPTION πŸ’–

okay so you pass a long β€” set it to 1L to turn it on, or 0 to turn it off. that's it, that's the vibe 🫢

what it actually does: it adds a request for compressed Transfer Encoding into your outgoing HTTP request. and like β€” if the server supports it and is feeling generous, it can clap back with an HTTP response sent using a compressed Transfer-Encoding. and the best part? libcurl automatically uncompresses that for you on reception. no cap, you don't have to do anything ✨

now here's the tea on why Transfer-Encoding is a whole different creature from the Content-Encoding you'd ask for with CURLOPT_ACCEPT_ENCODING(3): a Transfer-Encoding is strictly meant to be for the transfer itself, so it MUST be decoded before the data arrives in the client. non-negotiable, it's giving main character rules πŸ‘‘

and historically? Transfer-Encoding has been much less used and supported β€” by both HTTP clients AND HTTP servers. so like, lowkey rare. highkey iconic when it works. πŸ’€


πŸ“ DEFAULT πŸ“

0

(off by default, she's sleeping 😴)


🌈 PROTOCOLS 🌈

HTTP


πŸ”₯ EXAMPLE πŸ”₯

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
  curl_easy_setopt(curl, CURLOPT_TRANSFER_ENCODING, 1L);
  curl_easy_perform(curl);
}

look at her go 😭✨


⭐ AVAILABILITY ⭐

Added in 7.21.6 β€” vintage but still slaying πŸŽ€


πŸ’œ RETURN VALUE πŸ’œ

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. simple as that, bestie πŸ™ˆ


πŸ‘‘ SEE ALSO πŸ‘‘


πŸ’€ heads up: because Transfer-Encoding MUST be decoded before the data arrives in the client, this is not the same game as Content-Encoding. don't mix them up, i'm begging 🫢

mwah πŸ’‹ that's the whole page β€” brought to you by libcurl 7.37.0, dated 19 Jun 2014, and the letters GNURLOPT_T...R_ENCODING(3) which we simply must respect πŸ§šβ€β™€οΈπŸ’œ

πŸ“¦ where this page comes from