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