curl_mime_headers.3 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .TH curl_mime_headers 3 "22 August 2017" "libcurl" "libcurl"
  25. .SH NAME
  26. curl_mime_headers - set a mime part's custom headers
  27. .SH SYNOPSIS
  28. .nf
  29. #include <curl/curl.h>
  30. CURLcode curl_mime_headers(curl_mimepart *part,
  31. struct curl_slist *headers, int take_ownership);
  32. .fi
  33. .SH DESCRIPTION
  34. \fIcurl_mime_headers(3)\fP sets a mime part's custom headers.
  35. \fIpart\fP is the part's handle to assign the custom headers list to.
  36. \fIheaders\fP is the head of a list of custom headers; it may be set to NULL
  37. to remove a previously attached custom header list.
  38. \fItake_ownership\fP: when non-zero, causes the list to be freed upon
  39. replacement or mime structure deletion; in this case the list must not be
  40. freed explicitly.
  41. Setting a part's custom headers list multiple times is valid: only the value
  42. set by the last call is retained.
  43. .SH EXAMPLE
  44. .nf
  45. int main(void)
  46. {
  47. struct curl_slist *headers = NULL;
  48. CURL *easy = curl_easy_init();
  49. curl_mime *mime;
  50. curl_mimepart *part;
  51. headers = curl_slist_append(headers, "Custom-Header: mooo");
  52. mime = curl_mime_init(easy);
  53. part = curl_mime_addpart(mime);
  54. /* use these headers in the part, takes ownership */
  55. curl_mime_headers(part, headers, 1);
  56. /* pass on this data */
  57. curl_mime_data(part, "12345679", CURL_ZERO_TERMINATED);
  58. /* set name */
  59. curl_mime_name(part, "numbers");
  60. /* Post and send it. */
  61. curl_easy_setopt(easy, CURLOPT_MIMEPOST, mime);
  62. curl_easy_setopt(easy, CURLOPT_URL, "https://example.com");
  63. curl_easy_perform(easy);
  64. }
  65. .fi
  66. .SH AVAILABILITY
  67. As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
  68. .SH RETURN VALUE
  69. CURLE_OK or a CURL error code upon failure.
  70. .SH "SEE ALSO"
  71. .BR curl_mime_addpart (3),
  72. .BR curl_mime_name (3)