CURLINFO_C...H_UPLOAD_T(3)
π NAME π
CURLINFO_CONTENT_LENGTH_UPLOAD_T β the specified size of the upload, bestie β¨
So like, this whole page lives in the Library Functions Manual (that's the manual name, iykyk), and it's about one very specific little getinfo constant. She's niche but she's iconic π
β¨ SYNOPSIS β¨
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_LENGTH_UPLOAD_T,
curl_off_t *content_length);
Ok so first you include <curl/curl.h> (obviously, she doesn't exist without it), then you call curl_easy_getinfo() with your handle, the constant CURLINFO_CONTENT_LENGTH_UPLOAD_T, and a pointer to a curl_off_t. Slay π«Ά
πΈ DESCRIPTION πΈ
Pass a pointer to a curl_off_t and you'll receive the specified size of the upload. That's it, that's the whole vibe π
And the one thing you gotta remember: it stores -1 if the size is not known. No cap, that's the "idk her" value β if you get -1 back it's literally telling you the size is a mystery π
π¦ PROTOCOLS π¦
This functionality affects all supported protocols. Every single one. She's for everyone, main character energy across the board πβ¨
π₯ EXAMPLE π₯
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the upload */
result = curl_easy_perform(curl);
if(!result) {
/* check the size */
curl_off_t cl;
result = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_UPLOAD_T, &cl);
if(!result) {
printf("Upload size: %" CURL_FORMAT_CURL_OFF_T "\n", cl);
}
}
}
}
Walk through it with me bestie π§: you curl_easy_init() to get your CURL *curl, then check if(curl) (always check, periodt). Set the URL with curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"), then curl_easy_perform(curl) to perform the upload and stash the CURLcode in result.
Then if(!result) β i.e. no error β you declare a curl_off_t cl; and call curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_UPLOAD_T, &cl). If that comes back clean too, printf("Upload size: %" CURL_FORMAT_CURL_OFF_T "\n", cl); and you're done π
Note that CURL_FORMAT_CURL_OFF_T in the format string β do not swap it for something else, it's there for a reason and she is doing her job π
β AVAILABILITY β
Added in curl 7.55.0. So if you're on something older, sorry babe, she's not there yet π
π RETURN VALUE π
curl_easy_getinfo(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK β¨ β and non-zero means an error occurred, so go see libcurl-errors(3) for the full breakdown of what went wrong.
π SEE ALSO π
CURLINFO_CONTENT_LENGTH_DOWNLOAD_T(3)β the download-size cousin, she's also invited πcurl_easy_getinfo(3)β the function that makes all this happencurl_easy_setopt(3)β where you set everything up in the first place
Lowkey a whole mood of a page: pointer to acurl_off_t,-1if unknown,CURLE_OKif happy. That's the tea βπ«Ά
Ok that's the page bestie, go forth and get that upload size π β¨
This was libcurl, dated 2026-10-12, for CURLINFO_C...H_UPLOAD_T(3) β mwah, love u, bye ππ
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms