GNURLOPT_BUFFERSIZE(3)

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

πŸŽ€ GNURLOPT_BUFFERSIZE(3) πŸŽ€

okay bestie, this is from the curl_easy_setopt options manual, and it’s literally all about giving libcurl a preferred receive-buffer size. slay.


✨ NAME ✨

CURLOPT_BUFFERSIZE β€” set preferred receive buffer size. periodt.


🌸 SYNOPSIS 🌸

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_BUFFERSIZE, long size);

πŸ’– DESCRIPTION πŸ’–

bestie, you pass a long that says the size you prefer (in bytes) for libcurl’s receive buffer. the main point? your write callback gets called more often and with smaller chunks. secondly, for some protocols, there’s a benefit of having a larger buffer for performance. highkey a glow-up.

this is just treated as a request, not an order. you cannot be guaranteed to actually get the given size. no cap.

this buffer size is by default CURL_MAX_WRITE_SIZE (16kB). the maximum buffer size allowed to be set is CURL_MAX_READ_SIZE (512kB). the minimum buffer size allowed to be set is 1024. those are the numbers, bestie πŸ’…


πŸ¦‹ DEFAULT πŸ¦‹

CURL_MAX_WRITE_SIZE (16kB) β€” iconic default behavior 🫢


🌈 PROTOCOLS 🌈

All. every single one, we love an inclusive buffer option ✨


πŸ‘‘ EXAMPLE πŸ‘‘

here’s the whole vibe:

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/foo.bin");

  /* ask libcurl to allocate a larger receive buffer */
  curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 120000L);

  ret = curl_easy_perform(curl);

  curl_easy_cleanup(curl);
}

🧚 AVAILABILITY 🧚

Added in 7.10. Growing the buffer was added in 7.53.0. history bestie πŸ“œ


πŸ’œ RETURN VALUE πŸ’œ

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. that’s the whole return-value story, bestie 😌


⭐ SEE ALSO ⭐

these two are the SEE ALSO besties β€” go read them too, iykyk πŸ‘‘


mwah πŸ’‹ this page is from libcurl 7.37.0, dated 17 Jun 2014 β€” that’s the footer, bestie, catch you in the next manual πŸ«ΆπŸ’–

πŸ“¦ where this page comes from