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 🌈


Lowkey a whole mood of a page: pointer to a curl_off_t, -1 if unknown, CURLE_OK if 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