CURLINFO_C...DOWNLOAD_T(3)

πŸŽ€ CURLINFO_C...DOWNLOAD_T(3) πŸŽ€

okay bestie, welcome to CURLINFO_C...DOWNLOAD_T(3), straight out of the Library Functions Manual. This is literally the manual page for peeking at how big a download is gonna be. Very demure, very http, no cap. πŸ’…


πŸ’– NAME πŸ’–

CURLINFO_CONTENT_LENGTH_DOWNLOAD_T β€” content-length of download

✨ SYNOPSIS ✨

       #include <curl/curl.h>

       CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T,
                                  curl_off_t *content_length);

🌸 DESCRIPTION 🌸

okay so you pass a pointer to a curl_off_t and it receives the content-length of the download. This is the value read from the Content-Length: field. If the size is not known, it stores -1. That's the whole tea. πŸ«–

πŸ¦‹ PROTOCOLS πŸ¦‹

This functionality affects http only. That's the only protocol on the guest list for this one. πŸ’Œ

πŸ”₯ EXAMPLE πŸ”₯

Here's the example program, exactly as the manual shows it:

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

           /* Perform the request */
           result = curl_easy_perform(curl);

           if(!result) {
             /* check the size */
             curl_off_t cl;
             result =
               curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &cl);
             if(!result) {
               printf("Download size: %" CURL_FORMAT_CURL_OFF_T "\n", cl);
             }
           }
         }
       }

⭐ AVAILABILITY ⭐

Added in curl 7.55.0. πŸ’«

πŸ’€ RETURN VALUE πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the page, bestie 🫢 source/version: libcurl Β· date: 2026-10-12 Β· page: CURLINFO_C...DOWNLOAD_T(3) πŸ’–

πŸ“¦ where this page comes from