curl_mime_headers.3 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. .\" generated by cd2nroff 0.1 from curl_mime_headers.md
  2. .TH curl_mime_headers 3 "2025-01-17" libcurl
  3. .SH NAME
  4. curl_mime_headers \- set a mime part\(aqs custom headers
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_mime_headers(curl_mimepart *part,
  9. struct curl_slist *headers, int take_ownership);
  10. .fi
  11. .SH DESCRIPTION
  12. \fIcurl_mime_headers(3)\fP sets a mime part\(aqs custom headers.
  13. \fIpart\fP is the part\(aqs handle to assign the custom headers list to.
  14. \fIheaders\fP is the head of a list of custom headers; it may be set to NULL
  15. to remove a previously attached custom header list.
  16. \fItake_ownership\fP: when non\-zero, causes the list to be freed upon
  17. replacement or mime structure deletion; in this case the list must not be
  18. freed explicitly.
  19. Setting a part\(aqs custom headers list multiple times is valid: only the value
  20. set by the last call is retained.
  21. .SH PROTOCOLS
  22. This functionality affects http, imap and smtp
  23. .SH EXAMPLE
  24. .nf
  25. int main(void)
  26. {
  27. struct curl_slist *headers = NULL;
  28. CURL *easy = curl_easy_init();
  29. curl_mime *mime;
  30. curl_mimepart *part;
  31. headers = curl_slist_append(headers, "Custom-Header: mooo");
  32. mime = curl_mime_init(easy);
  33. part = curl_mime_addpart(mime);
  34. /* use these headers in the part, takes ownership */
  35. curl_mime_headers(part, headers, 1);
  36. /* pass on this data */
  37. curl_mime_data(part, "12345679", CURL_ZERO_TERMINATED);
  38. /* set name */
  39. curl_mime_name(part, "numbers");
  40. /* Post and send it. */
  41. curl_easy_setopt(easy, CURLOPT_MIMEPOST, mime);
  42. curl_easy_setopt(easy, CURLOPT_URL, "https://example.com");
  43. curl_easy_perform(easy);
  44. }
  45. .fi
  46. .SH AVAILABILITY
  47. Added in curl 7.56.0
  48. .SH RETURN VALUE
  49. CURLE_OK or a CURL error code upon failure.
  50. .SH SEE ALSO
  51. .BR curl_mime_addpart (3),
  52. .BR curl_mime_name (3)