curl_mime_encoder.3 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2021, 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. .\" **************************************************************************
  22. .TH curl_mime_encoder 3 "22 August 2017" "libcurl 7.56.0" "libcurl Manual"
  23. .SH NAME
  24. curl_mime_encoder - set a mime part's encoder and content transfer encoding
  25. .SH SYNOPSIS
  26. .nf
  27. #include <curl/curl.h>
  28. CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding);
  29. .fi
  30. .SH DESCRIPTION
  31. curl_mime_encoder() requests a mime part's content to be encoded before being
  32. transmitted.
  33. \fIpart\fP is the part's handle to assign an encoder.
  34. \fIencoding\fP is a pointer to a null-terminated encoding scheme. It may be
  35. set to NULL to disable an encoder previously attached to the part. The encoding
  36. scheme storage may safely be reused after this function returns.
  37. Setting a part's encoder multiple times is valid: only the value set by the
  38. last call is retained.
  39. Upon multipart rendering, the part's content is encoded according to the
  40. pertaining scheme and a corresponding \fI"Content-Transfer-Encoding"\fP header
  41. is added to the part.
  42. Supported encoding schemes are:
  43. .br
  44. "\fIbinary\fP": the data is left unchanged, the header is added.
  45. .br
  46. "\fI8bit\fP": header added, no data change.
  47. .br
  48. "\fI7bit\fP": the data is unchanged, but is each byte is checked
  49. to be a 7-bit value; if not, a read error occurs.
  50. .br
  51. "\fIbase64\fP": Data is converted to base64 encoding, then split in
  52. CRLF-terminated lines of at most 76 characters.
  53. .br
  54. "\fIquoted-printable\fP": data is encoded in quoted printable lines of
  55. at most 76 characters. Since the resulting size of the final data cannot be
  56. determined prior to reading the original data, it is left as unknown, causing
  57. chunked transfer in HTTP. For the same reason, this encoder may not be used
  58. with IMAP. This encoder targets text data that is mostly ASCII and should
  59. not be used with other types of data.
  60. If the original data is already encoded in such a scheme, a custom
  61. \fIContent-Transfer-Encoding\fP header should be added with
  62. \FIcurl_mime_headers\fP() instead of setting a part encoder.
  63. Encoding should not be applied to multiparts, thus the use of this
  64. function on a part with content set with \fIcurl_mime_subparts\fP() is
  65. strongly discouraged.
  66. .SH EXAMPLE
  67. .nf
  68. curl_mime *mime;
  69. curl_mimepart *part;
  70. /* create a mime handle */
  71. mime = curl_mime_init(easy);
  72. /* add a part */
  73. part = curl_mime_addpart(mime);
  74. /* send a file */
  75. curl_mime_filedata(part, "image.png");
  76. /* encode file data in base64 for transfer */
  77. curl_mime_encoder(part, "base64");
  78. .fi
  79. .SH AVAILABILITY
  80. As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
  81. .SH RETURN VALUE
  82. CURLE_OK or a CURL error code upon failure.
  83. .SH "SEE ALSO"
  84. .BR curl_mime_addpart "(3),"
  85. .BR curl_mime_headers "(3),"
  86. .BR curl_mime_subparts "(3)"