GNURLOPT_MAX_RECV_SPEED_LARGE(3)

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

πŸ’– GNURLOPT_MAX_RECV_SPEED_LARGE(3) πŸ’–

okay bestie so real quick β€” this page lives in the curl_easy_setopt options manual section, and it's about ONE thing: making your downloads chill tf out and not eat all the bandwidth. ✨


🌸 NAME 🌸

CURLOPT_MAX_RECV_SPEED_LARGE β€” rate limit data download speed πŸ’πŸ’¨

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAX_RECV_SPEED_LARGE,
                          curl_off_t maxspeed);

✨ DESCRIPTION ✨

so you pass a curl_off_t in as the parameter, right? and if a download exceeds this maxspeed β€” which is counted in bytes per second, no cap β€” the transfer will literally pause to keep the speed less than or equal to whatever value you gave it. default is unlimited speed, so if you're not touching this, go wild. 🌈

this is not an exact science, bestie. lowkey the whole point: libcurl attempts to keep the average speed below the given threshold over a period of time. it's vibes-based throttling, not a hard wall. 🫢

πŸ™ˆ heads up: if you set maxspeed to a value lower than CURLOPT_BUFFERSIZE(3), libcurl might download faster than the set limit initially. it's giving "running start", ngl.

and important β€” this option doesn't affect transfer speeds done with FILE:// URLs. local files do not care about your speed limits, periodt. πŸ’…

πŸŽ€ DEFAULT πŸŽ€

0, disabled

πŸ”₯ PROTOCOLS πŸ”₯

All but file://

πŸ‘‘ EXAMPLE πŸ‘‘

ok so this is how you actually do it:

CURL *curl = curl_easy_init();
if(curl) {
  CURLcode ret;
  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  /* cap the download speed to 31415 bytes/sec */
  curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, (curl_off_t)31415);
  ret = curl_easy_perform(curl);
}

see the 31415? that's your pi-flavored bandwidth cap, iconic. πŸ₯§ and yes you need that (curl_off_t) cast, don't skip it. 😭

⭐ AVAILABILITY ⭐

Added in 7.15.5 β€” so it's been around a minute. 🧚

πŸ’œ RETURN VALUE πŸ’œ

returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. simple as that, no mystery. πŸ¦‹

🌈 SEE ALSO 🌈


that's the whole page bestie, mwah πŸ’‹ officially brought to you by libcurl 7.37.0, dated 19 Jun 2014 β€” yeah she's vintage, but she still slays. πŸŽ€βœ¨πŸ’–

πŸ“¦ where this page comes from