GNURLOPT_POSTFIELDSIZE(3)
π 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
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms