curl_formget(3)

✨ curl_formget(3) β€” the multipart form POST chain serializer ✨

Okay bestie, so this one's from the libcurl manual, section 3 (library functions). Buckle up, because she's a deprecated icon and we still love her πŸ’…


🌸 NAME 🌸

curl_formget β€” serialize a multipart form POST chain

πŸŽ€ SYNOPSIS πŸŽ€

#include <curl/curl.h>

int curl_formget(struct curl_httppost * form, void *userp,
                 curl_formget_callback append);

πŸ’– DESCRIPTION πŸ’–

Heads up first, bestie: the form API (and that includes this function right here) is deprecated since libcurl 7.56.0. So she's giving legacy main character energy β€” still valid, still in the docs, but lowkey on her way out 🫢

curl_formget() serializes data that was previously built with curl_formadd(3). It takes a void pointer as its second argument named userp, and that gets passed straight through as the first argument to your curl_formget_callback function.

typedef size_t (*curl_formget_callback)(void *userp, const char *buf,
                                       size_t len);"

The curl_formget_callback gets invoked for each part of the HTTP POST chain. The character buffer handed to the callback must not be freed 😭 (not yours, don't touch). The callback should return the buffer length that was passed to it on success β€” that's the vibe check for "yes bestie, I ate that".

⚠️ Real talk: if the CURLFORM_STREAM option is used in the formpost, it prevents curl_formget(3) from working until you have performed the actual HTTP request. Why? Because only first then does libcurl know which actual read callback to use. It's giving "you can't have the receipts before the transaction" 🧚

πŸ¦‹ PROTOCOLS πŸ¦‹

This functionality affects http only 🌈

πŸ’œ EXAMPLE πŸ’œ

size_t print_httppost_callback(void *arg, const char *buf, size_t len)
{
  fwrite(buf, len, 1, stdout);
  *((size_t *)arg) += len;
  return len;
}

size_t print_httppost(struct curl_httppost *post)
{
  size_t total_size = 0;
  if(curl_formget(post, &total_size, print_httppost_callback)) {
    return (size_t)-1;
  }
  return total_size;
}

⭐ AVAILABILITY ⭐

Added in curl 7.15.5 β€” she's been around a minute, no cap πŸ‘‘

πŸ“ RETURN VALUE πŸ“

0 means everything was OK ✨, non-zero means an error occurred πŸ’€

🌈 SEE ALSO 🌈


πŸ’– and that's the whole page, bestie β€” go forth and serialize responsibly πŸ’–

Shoutout to the libcurl crew: this page is from the libcurl manual, dated 2026-10-12, and it's the curl_formget(3) page. Mwah πŸ’‹

πŸ“¦ where this page comes from