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