GNURLOPT_P...SIZE_LARGE(3)

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

πŸŽ€ GNURLOPT_POSTFIELDSIZE_LARGE β€” bestie's guide to the size of POST data pointed to πŸŽ€

Okay so this is a page from the gnurl manual, section 3 (GNURLOPT_P...SIZE_LARGE(3) β€” yes the title got squished by the terminal, she's fine) πŸ’…. Sit down, grab a strawberry drink πŸ“, and let's get into it.


✨ NAME ✨

CURLOPT_POSTFIELDSIZE_LARGE β€” literally the size of the POST data you're pointing at 🫢


✨ SYNOPSIS ✨

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POSTFIELDSIZE_LARGE,
                          curl_off_t size);

That's the whole vibe. You pass a curl_off_t called size and she slays πŸ¦‹


✨ DESCRIPTION ✨

Okay so picture this: you wanna post data to the server, but you do not want libcurl running strlen() to measure how big your data is. Then this option is the one πŸ‘‘. You must use it in that case β€” it's not optional, it's the whole point.

When you use this option, you can post fully binary data, which otherwise is likely to fail 😭 (binary + strlen() = disaster, no cap).

And if you set this size to -1, the library goes back to using strlen() to get the size. Yep, back to the old ways πŸ™ˆ


✨ DEFAULT ✨

-1


✨ PROTOCOLS ✨

HTTP(S) πŸ’–


✨ EXAMPLE ✨

Here's the whole thing, copy it exactly bestie:

CURL *curl = curl_easy_init();
if(curl) {
  const char *data = large_chunk;
  curl_off_t length_of_data; /* set somehow */

  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");

  /* size of the POST data */
  curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, length_of_data);

  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);

  curl_easy_perform(curl);
}

Notice the /* set somehow */ comment β€” that's not me being shady, that's literally what the page says. You gotta figure out that length yourself, bestie 🧚


✨ AVAILABILITY ✨

She ships along with HTTP 🌈


✨ RETURN VALUE ✨

  • Returns CURLE_OK if HTTP is supported πŸ’š
  • Returns CURLE_UNKNOWN_OPTION if it's not πŸ’€

That's it, that's the whole check.


✨ SEE ALSO ✨

(Yes, that last comma is living there rent free, and I'm not evicting her πŸŽ€)


tiny warning bb 🫢 β€” if you set a size that doesn't match your actual data, that's on you, not on me. This page only tells you what's written here, fr fr.

Okay that's the whole page, mwah πŸ’‹ β€” this cutie is from libcurl 7.37.0, dated 17 Jun 2014, so show her some respect, she's been iconic since before some of y'all were born πŸŒΈπŸ’œ

πŸ“¦ where this page comes from