GNURLOPT_T...R_ENCODING(3)
β¨ 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
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms