GNURLOPT_POSTFIELDSIZE(3)

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

πŸŽ€ GNURLOPT_POSTFIELDSIZE(3) β€” size of POST data pointed to πŸŽ€

okay bestie, gather round: this is a curl_easy_setopt options page, and it's all about telling gnurl the exact size of your POST data pointer. Main character energy for binary uploads, honestly. πŸ’…

✨ NAME ✨

CURLOPT_POSTFIELDSIZE β€” size of POST data pointed to

🌸 SYNOPSIS 🌸

#include <gnurl/curl.h>

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

πŸ¦‹ DESCRIPTION πŸ¦‹

So like, if you wanna post data to the server and you do not want libcurl doing a whole strlen() to measure the data size, you have to use this option. No cap. When this option is used, you can post fully binary data β€” which otherwise is likely to fail. Important vibe check: if this size is set to -1, the library will use strlen() to get the size.

And if you're posting more than 2GB? Do not try to make this one carry that load, bestie. Use CURLOPT_POSTFIELDSIZE_LARGE(3) instead. πŸ‘‘

πŸŽ€ DEFAULT πŸŽ€

-1

🌈 PROTOCOLS 🌈

HTTP

πŸ“ EXAMPLE πŸ“

CURL *curl = curl_easy_init();
if(curl) {
  const char *data = "data to send";

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

  /* size of the POST data */
  curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) strlen(data));

  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);

  curl_easy_perform(curl);
}

⭐ AVAILABILITY ⭐

Along with HTTP.

πŸ’– RETURN VALUE πŸ’–

Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. That's the whole tea. 🫢

πŸ‘‘ SEE ALSO πŸ‘‘


mwah πŸ’‹ β€” this lil page comes from libcurl 7.37.0, dated 17 Jun 2014. πŸ¦‹

πŸ“¦ where this page comes from