gnurl_mime_type(3)
π gnurl_mime_type π
okay so bestie, welcome to the libgnurl corner of the manual β this one's about gnurl_mime_type(3), and it's a lil' function that has ONE job and does it slayfully.
β¨ NAME β¨
curl_mime_type β sets a mime part's content type π
β¨ SYNOPSIS β¨
#include <gnurl/curl.h>
CURLcode curl_mime_type(curl_mimepart * part, const char * mimetype);
β¨ DESCRIPTION β¨
So curl_mime_type(3) sets a mime part's content type. That's it. That's the whole vibe. π¦
part is the part's handle β the one you're assigning the content type to, bestie. Like, the specific part you're dressing up.
mimetype points to the null-terminated file mime type string. And listen β it may be set to NULL to remove a previously attached mime type. So if you change your mind, no cap, you can just yeet it. π
The mime type string is copied into the part, so the associated storage may safely be released or reused after the call. ngl that's the polite thing to do. Setting a part's type twice is totally valid: only the value set by the last call is retained. Last one wins, periodt. π
In the absence of a mime type and if needed by the protocol specifications, a default mime type is determined by the context:
- If set as a custom header, use this value.
application/form-datafor an HTTP form post.- If a remote file name is set, the mime type is taken from the file name extension, or
application/octet-streamby default. - For a multipart part,
multipart/mixed. text/plainin other cases.
so yeah, it's giving "the function has a fallback plan for every situation" energy. πΈ
β¨ AVAILABILITY β¨
Works as long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0. β¨
β¨ RETURN VALUE β¨
You get CURLE_OK if it ate, or a CURL error code upon failure. π
β¨ EXAMPLE β¨
curl_mime *mime;
curl_mimepart *part;
/* create a mime handle */
mime = curl_mime_init(easy);
/* add a part */
part = curl_mime_addpart(mime);
/* get data from this file */
curl_mime_filedata(part, "image.png");
/* content-type for this part */
curl_mime_type(part, "image/png");
/* set name */
curl_mime_name(part, "image");
look at that. main character code, honestly. π₯
β¨ SEE ALSO β¨
and that's the whole page, bestie!! π«Ά this lil' writeup lives in the libcurl 7.56.0 era, dated 22 August 2017 β so go forth, set those mime types, and remember: only the last call is retained. iykyk ππ
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms