GNURLOPT_M...SIZE_LARGE(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’… GNURLOPT_M...SIZE_LARGE(3) β€” CURLOPT_MAXFILESIZE_LARGE

okay so this page lives in the curl_easy_setopt options manual, and the manual name is literally GNURLOPT_M...SIZE_LARGE(3). The option we’re talking about is CURLOPT_MAXFILESIZE_LARGE, and it’s giving β€œset a max file size or else” energy. Let’s go ✨


🌸 NAME 🌸

  • CURLOPT_MAXFILESIZE_LARGE β€” maximum file size allowed to download

✨ SYNOPSIS ✨

The include and signature are locked in, no cap:

#include <gnurl/curl.h>

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

πŸ’– DESCRIPTION πŸ’–

You pass a curl_off_t as the parameter. That’s how you specify the maximum size (in bytes) of a file to download. If the requested file is found larger than this value, the transfer will not start, and CURLE_FILESIZE_EXCEEDED will be returned. Slay? More like slam the brakes πŸ’€

important caveat, and I mean listen: the file size is not always known prior to download. For such files, this option has no effect, even if the file transfer ends up being larger than the given limit. This concerns both FTP and HTTP transfers. So it’s not a magical universal big-file blocker, bestie β€” it’s a β€œwhen we know the size” situation.

πŸŽ€ DEFAULT πŸŽ€

None. No default cap, no drama, just None.

🌈 PROTOCOLS 🌈

FTP and HTTP β€” that’s the whole vibe check.

πŸ¦‹ EXAMPLE πŸ¦‹

Here’s the example, copied exactly and looking iconic:

CURL *curl = curl_easy_init();
if(curl) {
  CURLcode ret;
  curl_off_t ridiculous = 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);
  ret = curl_easy_perform(curl);
}

⭐ AVAILABILITY ⭐

Added in 7.11.0. Vintage but still serving πŸ’…

πŸ’€ RETURN VALUE πŸ’€

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. That’s the whole return-value tea.

πŸ”₯ SEE ALSO πŸ”₯

Go read CURLOPT_MAXFILESIZE(3), CURLOPT_MAX_RECV_SPEED_LARGE(3), β€” and yes bestie, that trailing comma is in the original, leave it alone, it’s part of the lore. iykyk.


mwah πŸ’– source/version: libcurl 7.37.0; date: 19 Jun 2014; manual name: GNURLOPT_M...SIZE_LARGE(3). That’s the footer folded cute, periodt. 🫢

πŸ“¦ where this page comes from