GNURLOPT_HTTPPOST(3)

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

✨ NAME ✨

okay so bestie, welcome to GNURLOPT_HTTPPOST(3) from the curl_easy_setopt options manual β€” this is literally all about CURLOPT_HTTPPOST, aka the option that lets you specify the multipart formpost content. no cap, that's the vibe. πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPPOST,
                          struct curl_httppost *formpost);

that's the signature, bestie β€” exact and iconic. 🫢

🌸 DESCRIPTION 🌸

so here's the tea: this tells libcurl you want a multipart/formdata HTTP POST to be made, and you instruct what data to pass on to the server in the formpost argument. pass a pointer to a linked list of curl_httppost structs as the parameter. the easiest way to create such a list is to use curl_formadd(3) as documented. the data in this list must remain intact as long as the curl transfer is alive and is using it β€” fr fr, do not let that data ghost the transfer. 😭

using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. you can disable this header with CURLOPT_HTTPHEADER(3).

when setting CURLOPT_HTTPPOST(3), it will automatically set CURLOPT_NOBODY(3) to 0.

🚨 This option is deprecated! Do not use it. use CURLOPT_MIMEPOST(3) instead after having prepared mime data. that's the whole warning, bestie β€” it's giving vintage, not current. πŸ’€

πŸŽ€ DEFAULT πŸŽ€

NULL

literally the default is NULL β€” empty, quiet, no formpost drama. 🫢

πŸ’… PROTOCOLS πŸ’…

HTTP

that's the only protocol on the guest list, periodt. πŸ‘‘

πŸ”₯ EXAMPLE πŸ”₯

here's the example, copied exactly so you can see the whole formpost situation:

/* Fill in the file upload field. This makes libcurl load data from
   the given file name when curl_easy_perform() is called. */
curl_formadd(&formpost,
             &lastptr,
             CURLFORM_COPYNAME, "sendfile",
             CURLFORM_FILE, "postit2.c",
             CURLFORM_END);

/* Fill in the filename field */
curl_formadd(&formpost,
             &lastptr,
             CURLFORM_COPYNAME, "filename",
             CURLFORM_COPYCONTENTS, "postit2.c",
             CURLFORM_END);

/* Fill in the submit field too, even if this is rarely needed */
curl_formadd(&formpost,
             &lastptr,
             CURLFORM_COPYNAME, "submit",
             CURLFORM_COPYCONTENTS, "send",
             CURLFORM_END);

🌈 AVAILABILITY 🌈

as long as HTTP is enabled. deprecated in 7.56.0.

⭐ RETURN VALUE ⭐

returns CURLE_OK if HTTP is enabled, and CURLE_UNKNOWN_OPTION if not.

πŸ‘‘ SEE ALSO πŸ‘‘

go read these next, bestie:


okay that's the page πŸ’– it's from libcurl 7.37.0, dated 17 Jun 2014, and it's giving GNURLOPT_HTTPPOST(3) energy from the curl_easy_setopt options manual. slay, periodt, bye bestie βœ¨πŸ’…

πŸ“¦ where this page comes from