gnurl_mime_headers(3)

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

πŸ’… gnurl_mime_headers(3) β€” bestie's guide to custom mime part headers

okay so we're in the libgnurl Manual (libgnurl, yes, the gnurl-flavoured curl docs) and today's main character is gnurl_mime_headers(3). buckle up, this one's short but she matters πŸŽ€


✨ NAME ✨

curl_mime_headers β€” set a mime part's custom headers

(yes bestie, the function inside is called curl_mime_headers, the page is called gnurl_mime_headers. it's giving rebrand. don't overthink it πŸ’…)


🌸 SYNOPSIS 🌸

#include <gnurl/curl.h>

CURLcode curl_mime_headers(curl_mimepart * part, struct curl_slist *
headers, int take_ownership);

like all good things, she returns a CURLcode and takes three things. let's meet them 🫢


πŸ’– DESCRIPTION πŸ’–

curl_mime_headers(3) sets a mime part's custom headers. that's the whole vibe. no cap.

  • part β€” the part's handle you're assigning the custom headers list to. your little mime part bestie 🧚
  • headers β€” the head of a list of custom headers. and listen, it may be set to NULL to remove a previously attached custom header list. so NULL is not a bug, it's a personality reset ✨
  • take_ownership β€” when non-zero, it causes the list to be freed upon replacement or mime structure deletion. in that case the list must not be freed explicitly. read that again. like, do not double-free her, she's taken πŸ™ˆ
lowkey important: setting a part's custom headers list twice is valid: only the value set by the last call is retained. so no drama, the newest one wins πŸ‘‘

πŸ¦‹ AVAILABILITY πŸ¦‹

as long as at least one of HTTP, SMTP or IMAP is enabled. added in 7.56.0. so if you're on something ancient, sorry bestie, no headers for you 😭


⭐ RETURN VALUE ⭐

CURLE_OK or a CURL error code upon failure. that's it, that's the whole return value. check it, periodt πŸ’€


πŸ”₯ EXAMPLE πŸ”₯

here's the glow-up demo, copied exactly so you can paste it and slay:

 struct curl_slist *headers = NULL;

 headers = curl_slist_append("Custom-Header: mooo", headers);

 /* use these headers, please take ownership */
 curl_mime_headers(part, headers, TRUE);

 /* pass on this data */
 curl_mime_data(part, "12345679", CURL_ZERO_TERMINATED);

 /* set name */
 curl_mime_name(part, "numbers");

the way she says "please take ownership" 😭 iconic. and yes, that string is literally "Custom-Header: mooo". we love a cow moment πŸ„


🌈 SEE ALSO 🌈


and that's the page! πŸŽ€ no notes, she ate. this gem came from libcurl 7.56.0, dated 22 August 2017, and the page itself is gnurl_mime_headers(3) β€” love her, read her, use her responsibly πŸ’œπŸ’…

πŸ“¦ where this page comes from