GNURLOPT_U...BUFFERSIZE(3)

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

πŸ’… GNURLOPT_UPLOAD_BUFFERSIZE(3) β€” like, the upload-buffer-size one, bestie

okay so real talk, this one lives in the gnurl/curl.h corner of the world (that's the gnurl flavour of the curl_easy_setopt options crew, iykyk), and it's genuinely one of those "small flag, big mood" situations 🫢


✨ NAME ✨

CURLOPT_UPLOAD_BUFFERSIZE β€” set your preferred upload buffer size, queen πŸ‘‘


🌸 SYNOPSIS 🌸

#include <gnurl/curl.h>

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

πŸ¦‹ DESCRIPTION πŸ¦‹

so you pass a long that says what size (in bytes, btw) you want the upload buffer in libcurl to be. and then libcurl goes and uses a bigger buffer that gets passed to the next layer down the stack so it can get sent off. and honestly? in some setups, and for some protocols, having a larger upload buffer is a huge performance benefit. like, not me being dramatic, it's literally in the docs. πŸ”₯

⚠️ but listen β€” this is treated as a request, not an order. you are not guaranteed to actually get the size you asked for. the vibes are advisory only. 😭

the upload buffer size is by default 64 kilobytes. the maximum buffer size you're allowed to set is 2 megabytes. the minimum buffer size you're allowed to set is 16 kilobytes. so like, stay in your lane between those, bestie πŸ’…

and since curl 7.61.1 the upload buffer is allocated on-demand β€” so if the handle isn't used for upload, the buffer will not be allocated at all. we love a lazy-allocating icon who doesn't do work that isn't needed ✨


πŸŽ€ DEFAULT πŸŽ€

64 kB β€” the standard-issue vibe, no cap


🌈 PROTOCOLS 🌈

All of them. every single one. main character energy across the board πŸ‘‘


πŸ’– EXAMPLE πŸ’–

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

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

  ret = curl_easy_perform(curl);

  curl_easy_cleanup(curl);
}

see that 120000L? that's the "please give me a bigger buffer" ask πŸ₯Ί and the comment in the middle is literally there to explain itself, we stan a self-documenting codebase.


⭐ AVAILABILITY ⭐

Added in 7.62.0. so if you're on something older, this option is giving "not invited to the party" πŸ’€


🧚 RETURN VALUE 🧚

returns CURLE_OK if the option is supported β€” slay βœ…

and returns CURLE_UNKNOWN_OPTION if it's not β€” sad but valid πŸ™ˆ


πŸ”₯ SEE ALSO πŸ”₯

(that trailing comma in the original? iconic. we keep it. periodt.)


and that's the whole page, bestie πŸ’œ it's from libcurl 7.62.0, dated 18 Aug 2018, filed under the very dramatic GNURLOPT_U...BUFFERSIZE(3) header because apparently even manpage titles get the abridged treatment πŸŽ€ go forth and buffer responsibly πŸ¦‹

πŸ“¦ where this page comes from