1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_MIME_OPTIONS
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_HTTPPOST (3)
9  - CURLOPT_MIMEPOST (3)
10Protocol:
11  - HTTP
12  - IMAP
13  - SMTP
14---
15
16# NAME
17
18CURLOPT_MIME_OPTIONS - set MIME option flags
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIME_OPTIONS, long options);
26~~~
27
28# DESCRIPTION
29
30Pass a long that holds a bitmask of CURLMIMEOPT_* defines. Each bit is a
31Boolean flag used while encoding a MIME tree or multipart form data.
32
33Available bits are:
34
35## CURLMIMEOPT_FORMESCAPE
36
37Tells libcurl to escape multipart form field and filenames using the
38backslash-escaping algorithm rather than percent-encoding (HTTP only).
39
40Backslash-escaping consists in preceding backslashes and double quotes with
41a backslash. Percent encoding maps all occurrences of double quote,
42carriage return and line feed to %22, %0D and %0A respectively.
43
44Before version 7.81.0, percent-encoding was never applied.
45
46HTTP browsers used to do backslash-escaping in the past but have over time
47transitioned to use percent-encoding. This option allows one to address
48server-side applications that have not yet have been converted.
49
50As an example, consider field or filename *strangename"kind*. When the
51containing multipart form is sent, this is normally transmitted as
52*strangename%22kind*. When this option is set, it is sent as
53*strangename"kind*.
54
55# DEFAULT
56
570, meaning disabled.
58
59# EXAMPLE
60
61~~~c
62int main(void)
63{
64  CURL *curl = curl_easy_init();
65  curl_mime *form = NULL;
66
67  if(curl) {
68    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
69    curl_easy_setopt(curl, CURLOPT_MIME_OPTIONS, CURLMIMEOPT_FORMESCAPE);
70
71    form = curl_mime_init(curl);
72    if(form) {
73      curl_mimepart *part = curl_mime_addpart(form);
74
75      if(part) {
76        curl_mime_filedata(part, "strange\\file\\name");
77        curl_mime_name(part, "strange\"field\"name");
78        curl_easy_setopt(curl, CURLOPT_MIMEPOST, form);
79
80        /* Perform the request */
81        curl_easy_perform(curl);
82      }
83    }
84
85    curl_easy_cleanup(curl);
86    curl_mime_free(form);
87  }
88}
89~~~
90
91# AVAILABILITY
92
93Option added in 7.81.0.
94
95# RETURN VALUE
96
97Returns CURLE_OK
98