1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: curl_mime_headers 5Section: 3 6Source: libcurl 7See-also: 8 - curl_mime_addpart (3) 9 - curl_mime_name (3) 10Protocol: 11 - HTTP 12 - IMAP 13 - SMTP 14--- 15 16# NAME 17 18curl_mime_headers - set a mime part's custom headers 19 20# SYNOPSIS 21 22~~~c 23#include <curl/curl.h> 24 25CURLcode curl_mime_headers(curl_mimepart *part, 26 struct curl_slist *headers, int take_ownership); 27~~~ 28 29# DESCRIPTION 30 31curl_mime_headers(3) sets a mime part's custom headers. 32 33*part* is the part's handle to assign the custom headers list to. 34 35*headers* is the head of a list of custom headers; it may be set to NULL 36to remove a previously attached custom header list. 37 38*take_ownership*: when non-zero, causes the list to be freed upon 39replacement or mime structure deletion; in this case the list must not be 40freed explicitly. 41 42Setting a part's custom headers list multiple times is valid: only the value 43set by the last call is retained. 44 45# EXAMPLE 46 47~~~c 48int main(void) 49{ 50 struct curl_slist *headers = NULL; 51 CURL *easy = curl_easy_init(); 52 curl_mime *mime; 53 curl_mimepart *part; 54 55 headers = curl_slist_append(headers, "Custom-Header: mooo"); 56 57 mime = curl_mime_init(easy); 58 part = curl_mime_addpart(mime); 59 60 /* use these headers in the part, takes ownership */ 61 curl_mime_headers(part, headers, 1); 62 63 /* pass on this data */ 64 curl_mime_data(part, "12345679", CURL_ZERO_TERMINATED); 65 66 /* set name */ 67 curl_mime_name(part, "numbers"); 68 69 /* Post and send it. */ 70 curl_easy_setopt(easy, CURLOPT_MIMEPOST, mime); 71 curl_easy_setopt(easy, CURLOPT_URL, "https://example.com"); 72 curl_easy_perform(easy); 73} 74~~~ 75 76# AVAILABILITY 77 78As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0. 79 80# RETURN VALUE 81 82CURLE_OK or a CURL error code upon failure. 83