1CURLOPT_MIME_OPTIONS(3)             libcurl            CURLOPT_MIME_OPTIONS(3)
2
3
4

NAME

6       CURLOPT_MIME_OPTIONS - set MIME option flags
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIME_OPTIONS, long options);
12

DESCRIPTION

14       Pass  a long that holds a bitmask of CURLMIMEOPT_* defines. Each bit is
15       a Boolean flag used while encoding a MIME tree or multipart form data.
16
17       Available bits are:
18
19       CURLMIMEOPT_FORMESCAPE
20              Tells libcurl to escape multipart form field and file names  us‐
21              ing  the backslash-escaping algorithm rather than percent-encod‐
22              ing (HTTP only).
23
24              Backslash-escaping consists in preceding backslashes and  double
25              quotes  with  a backslash. Percent encoding maps all occurrences
26              of double quote, carriage return and line feed to %22,  %0D  and
27              %0A respectively.
28
29              Before version 7.81.0, percent-encoding was never applied.
30
31              HTTP browsers used to do backslash-escaping in the past but have
32              over time transitioned to use percent-encoding. This option  al‐
33              lows  one  to address server-side applications that have not yet
34              have been converted.
35
36              As an example, consider field or  file  name  strange\name"kind.
37              When  the  containing  multipart  form is sent, this is normally
38              transmitted as strange\name%22kind. When this option is set,  it
39              is sent as strange\\name\"kind.
40

DEFAULT

42       0, meaning disabled.
43

PROTOCOLS

45       HTTP, IMAP, SMTP
46

EXAMPLE

48       CURL *curl = curl_easy_init();
49       curl_mime *form = NULL;
50
51       if(curl) {
52         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
53         curl_easy_setopt(curl, CURLOPT_MIME_OPTIONS, CURLMIMEOPT_FORMESCAPE);
54
55         form = curl_mime_init(curl);
56         if(form) {
57           curl_mimepart *part = curl_mime_addpart(form);
58
59           if(part) {
60             curl_mime_filedata(part, "strange\\file\\name");
61             curl_mime_name(part, "strange\"field\"name");
62             curl_easy_setopt(curl, CURLOPT_MIMEPOST, form);
63
64             /* Perform the request */
65             curl_easy_perform(curl);
66           }
67         }
68
69         curl_easy_cleanup(curl);
70         curl_mime_free(mime);
71       }
72

AVAILABILITY

74       Option added in 7.81.0.
75

RETURN VALUE

77       Returns CURLE_OK
78

SEE ALSO

80       CURLOPT_MIMEPOST(3), CURLOPT_HTTPPOST(3)
81
82
83
84ibcurl 8.2.1                    April 26, 2023         CURLOPT_MIME_OPTIONS(3)
Impressum