CURLOPT_LOW_SPEED_LIMIT(3)

πŸ’… CURLOPT_LOW_SPEED_LIMIT(3) β€” the "girl, this transfer is too slow, wrap it up" option ✨

okay so real talk: this is a page from the Library Functions Manual, and it's about CURLOPT_LOW_SPEED_LIMIT(3) β€” the low speed limit, in bytes per second. yes bestie, we're doing throttle-detection today and it's actually iconic. πŸ’πŸ’€


🌸 NAME 🌸

CURLOPT_LOW_SPEED_LIMIT β€” low speed limit in bytes per second. that's it, that's the whole vibe check. πŸŽ€


✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOW_SPEED_LIMIT,
                          long speedlimit);

so you're passing a long in as speedlimit and honestly that's the whole plot 🫢


πŸ’– DESCRIPTION πŸ’–

okay so listen: you pass a long as the parameter. that number is the average transfer speed in bytes per second that the transfer should be below β€” for CURLOPT_LOW_SPEED_TIME(3) whole seconds β€” before libcurl goes "nope, this is too slow, I'm out" and aborts the transfer. 😭

like it's giving "if you're not gonna move at least this fast for this long, we're done here." main character boundary setting fr fr. πŸ‘‘


πŸŽ€ DEFAULT πŸŽ€

0, disabled β€” meaning by default nobody's judging your speed. no cap. πŸ™ˆ


πŸ¦‹ PROTOCOLS πŸ¦‹

this functionality affects all supported protocols. every single one. no one is exempt πŸ’…


πŸ”₯ EXAMPLE πŸ”₯

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
    /* abort if slower than 30 bytes/sec during 60 seconds */
    curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 60L);
    curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 30L);
    result = curl_easy_perform(curl);
    if(CURLE_OPERATION_TIMEDOUT == result) {
      printf("Timeout.\n");
    }
    /* always cleanup */
    curl_easy_cleanup(curl);
  }
}

see how CURLOPT_LOW_SPEED_TIME and CURLOPT_LOW_SPEED_LIMIT are besties here? 60 seconds + 30 bytes/sec = "if you're under 30 B/s for a full minute, we abort." and then we check for CURLE_OPERATION_TIMEDOUT like the queen we are. also don't forget curl_easy_cleanup(curl) β€” always cleanup, that comment is literally in the code for a reason 🫢✨


⭐ AVAILABILITY ⭐

added in curl 7.1. vintage. retro. still slaying. πŸ’œ


🌈 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 β€” go check libcurl-errors(3) πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the page!! mwah πŸ’‹ signed off from libcurl, dated 2026-10-12 β€” go set your speed limits, bestie, and remember: slow transfers are not your fault but they are something you can abort on. πŸ§šβ€β™€οΈπŸ’–

πŸ“¦ where this page comes from