CURLOPT_MAXFILESIZE_LARGE(3)

πŸ’… CURLOPT_MAXFILESIZE_LARGE(3) β€” like, the libcurl manual bestie πŸŽ€

okay so this is a page from the Library Functions Manual and it's about setting a maximum file size you're willing to download. no cap, it's more useful than it sounds. let's get into it ✨


🌸 NAME 🌸

CURLOPT_MAXFILESIZE_LARGE β€” the maximum file size allowed to download, bestie. that's the whole vibe.


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXFILESIZE_LARGE,
                          curl_off_t size);

✨ DESCRIPTION ✨

so you pass a curl_off_t as the parameter, okay? this specifies the maximum accepted size (in bytes) of a file to download. if the file you requested turns out to be larger than this value, the transfer is aborted and CURLE_FILESIZE_EXCEEDED is returned. slay, boundaries πŸ’…

passing a zero size disables this whole thing, and passing a negative size yields a CURLE_BAD_FUNCTION_ARGUMENT (as it should, honestly, negative file sizes are not the moment πŸ™ˆ).

girlies listen up: the file size is not always known prior to the download start, and for such transfers this option has no effect β€” even if the file transfer eventually ends up being larger than this given limit. so like, it can't save you in every scenario, just so you know 😭

since 8.4.0, this option also stops ongoing transfers if they reach this threshold. she's proactive now, we love growth πŸ‘‘


πŸ’– DEFAULT πŸ’–

0, meaning disabled. the "no thoughts, head empty" default.


🌈 PROTOCOLS 🌈

this functionality affects ftp, http and mqtt


🧚 EXAMPLE 🧚

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_off_t ridiculous = (curl_off_t)1 << 48;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
    /* refuse to download if larger than ridiculous */
    curl_easy_setopt(curl, CURLOPT_MAXFILESIZE_LARGE, ridiculous);
    result = curl_easy_perform(curl);
  }
}

the variable is literally called ridiculous and honestly? iconic. (curl_off_t)1 << 48 is a whole lotta bytes and that's the point πŸ’€


⭐ AVAILABILITY ⭐

Added in curl 7.11.0 β€” she's been around a minute, respect the elders 🫢


πŸ”₯ RETURN VALUE πŸ”₯

curl_easy_setopt(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3). like, go read that one if something's acting up, iykyk.


πŸ‘‘ SEE ALSO πŸ‘‘

the whole friend group, fr fr πŸ’œ


and that's the whole page, bestie β€” mwah πŸ’‹ this manual page came to you from libcurl, dated 2026-10-12, and yes she ate πŸ’…βœ¨

πŸ“¦ where this page comes from