CURLOPT_HTTPPOST(3)
π CURLOPT_HTTPPOST(3) β multipart formpost content π
Okay bestie, welcome to the libcurl manual page for CURLOPT_HTTPPOST β it lives in the Library Functions Manual, and it is lowkey a legacy icon that still deserves its flowers. β¨
πΈ NAME πΈ
CURLOPT_HTTPPOST β multipart formpost content π
π¦ SYNOPSIS π¦
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPPOST,
struct curl_httppost *formpost);
β¨ DESCRIPTION β¨
Okay so first things first, bestie: this option is deprecated. Not kidding, not being dramatic β it literally says so. Use CURLOPT_MIMEPOST(3) instead, periodt. π
This option tells libcurl that you want a multipart/formdata HTTP POST to happen, and you use the formpost argument to tell it what data to send to the server. You pass a pointer to a linked list of curl_httppost structs as the parameter. The easiest way to create that list is to use curl_formadd(3) as documented. π«Ά
The data in this list must remain intact for as long as the curl transfer is alive and using it β like, don't let it ghost the transfer, okay? π
Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. You can disable that header with CURLOPT_HTTPHEADER(3), if that's your vibe. π¦
When you set CURLOPT_HTTPPOST(3), libcurl automatically sets CURLOPT_NOBODY(3) to 0. Not me noticing that little automatic slay. π
π DEFAULT π
NULL
Like, no formpost unless you bring one. π
π PROTOCOLS π
This functionality affects http only.
Http girlies only, no cap. π
π EXAMPLE π
int main(void)
{
struct curl_httppost *formpost;
struct curl_httppost *lastptr;
/* 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);
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
curl_formfree(formpost);
}
It's giving classic C example realness, and honestly? Ate. π₯
πΈ DEPRECATED πΈ
Deprecated in 7.56.0.
Yep, she's been officially put on notice since 7.56.0. Still iconic, but use CURLOPT_MIMEPOST(3) if you're starting fresh, bestie. π
β AVAILABILITY β
Added in curl 7.1
Old-school legend behavior, fr fr. π
π RETURN VALUE π
curl_easy_setopt(3) returns a CURLcode indicating success or error. π
CURLE_OK (0) means everything was OK. A non-zero value means an error occurred β see libcurl-errors(3) for all the details.
π§ SEE ALSO π§
CURLOPT_MIMEPOST(3)CURLOPT_POST(3)CURLOPT_POSTFIELDS(3)curl_formadd(3)curl_formfree(3)curl_mime_init(3)
Go read those too, iykyk. πβ¨
Sign-off tea β: this page comes from libcurl, dated 2026-10-12, and the manual page title is CURLOPT_HTTPPOST(3). Stay multipart, stay hydrated, and remember: deprecated does not mean forgotten. π
ππ¦
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms