2
0

curl_mime_encoder.3 3.7 KB

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