GNURLOPT_MAX_RECV_SPEED_LARGE(3)
π 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 setmaxspeedto a value lower thanCURLOPT_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
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms