curl_mime_name(3)

πŸ’… curl_mime_name(3) β€” like, the whole manual, bestie

okay so this is a page from the Library Functions Manual β€” it's curl_mime_name(3), and it's genuinely one of the cutest little functions in libcurl. grab a strawberry drink πŸ“ and let's get into it.


✨ NAME ✨

curl_mime_name β€” set a mime part's name (yes, that's literally it, and yes, it's iconic)


πŸŽ€ SYNOPSIS πŸŽ€

#include <curl/curl.h>

CURLcode curl_mime_name(curl_mimepart *part, const char *name);

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so here's the vibe: curl_mime_name(3) sets a mime part's name. That's the way HTTP form fields are named, iykyk. no cap, this is the function doing the naming.

part is the part's handle β€” the thing you're assigning a name to. main character energy.

name points to the null-terminated name string. simple.

Now the important bit, pay attention bestie: the name string gets copied into the part, so the associated storage may safely be released or reused after the call. 🫢 you don't have to keep it alive, it's fine, let it go.

Setting a part's name multiple times is valid β€” only the value set by the last call is retained. last one wins, periodt. πŸ’…

And you can reset the name of a part by setting name to NULL. poof, gone. 🧚


🌈 PROTOCOLS 🌈

this functionality affects http, imap and smtp πŸ’œ


πŸ”₯ EXAMPLE πŸ”₯

here's the whole thing, verbatim, no edits:

int main(void)
{
  curl_mime *mime;
  curl_mimepart *part;

  CURL *curl = curl_easy_init();
  if(curl) {
    /* create a mime handle */
    mime = curl_mime_init(curl);

    /* add a part */
    part = curl_mime_addpart(mime);

    /* give the part a name */
    curl_mime_name(part, "shoe_size");
  }
}

"shoe_size" bestie. we're naming a shoe size. iconic. πŸ‘‘


⭐ AVAILABILITY ⭐

Added in curl 7.56.0 β€” so it's been old enough to drive for a minute, ngl.


πŸ’– RETURN VALUE πŸ’–

This function returns a CURLcode indicating success or error.

  • CURLE_OK (0) means everything was OK β€” slay, we ate. ✨
  • non-zero means an error occurred, see libcurl-errors(3) 😭
  • If CURLOPT_ERRORBUFFER(3) was set with curl_easy_setopt(3) there can be an error message stored in the error buffer when non-zero is returned. so helpful, fr fr.
reminder bestie: non-zero is not a vibe. check that error buffer. πŸ’€

🌸 SEE ALSO 🌸

go read them, they're all part of the same little mime family πŸŽ€


and that's the page! footer vibes for the record: this is libcurl, dated 2026-10-12, and it's the curl_mime_name(3) page β€” mwah, love that for us. πŸ’‹βœ¨

πŸ“¦ where this page comes from