Go to main content

man pages section 3: Library Interfaces and Headers

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

CURLOPT_MIME_OPTIONS (3)

Name

CURLOPT_MIME_OPTIONS - set MIME option flags

Synopsis

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIME_OPTIONS, long options);

Description

CURLOPT_MIME_OPTIONS(3)    curl_easy_setopt options    CURLOPT_MIME_OPTIONS(3)



NAME
       CURLOPT_MIME_OPTIONS - set MIME option flags

SYNOPSIS
       #include <curl/curl.h>

       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIME_OPTIONS, long options);

DESCRIPTION
       Pass  a long that holds a bitmask of CURLMIMEOPT_* defines. Each bit is
       a Boolean flag used while encoding a MIME tree or multipart form data.

       Available bits are:

       CURLMIMEOPT_FORMESCAPE
              Tells libcurl to escape multipart  form  field  and  file  names
              using  the  backslash-escaping  algorithm  rather  than percent-
              encoding (HTTP only).

              Backslash-escaping consists in preceding backslashes and  double
              quotes  with  a backslash. Percent encoding maps all occurrences
              of double quote, carriage return and line feed to %22,  %0D  and
              %0A respectively.

              Before version 7.81.0, percent-encoding was never applied.

              HTTP browsers used to do backslash-escaping in the past but have
              over time transitioned  to  use  percent-encoding.  This  option
              allows  to  address  server-side  applications that have not yet
              have been converted.

              As an example, consider field or  file  name  strange\name"kind.
              When  the  containing  multipart  form is sent, this is normally
              transmitted as strange\name%22kind. When this option is set,  it
              is sent as strange\\name\"kind.

DEFAULT
       0, meaning disabled.

PROTOCOLS
       HTTP, IMAP, SMTP

EXAMPLE
       CURL *curl = curl_easy_init();
       curl_mime *form = NULL;

       if(curl) {
         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
         curl_easy_setopt(curl, CURLOPT_MIME_OPTIONS, CURLMIMEOPT_FORMESCAPE);

         form = curl_mime_init(curl);
         if(form) {
           curl_mimepart *part = curl_mime_addpart(form);

           if(part) {
             curl_mime_filedata(part, "strange\\file\\name");
             curl_mime_name(part, "strange\"field\"name");
             curl_easy_setopt(curl, CURLOPT_MIMEPOST, form);

             /* Perform the request */
             curl_easy_perform(curl);
           }
         }

         curl_easy_cleanup(curl);
         curl_mime_free(mime);
       }

AVAILABILITY
       Option added in 7.81.0.

RETURN VALUE
       Returns CURLE_OK


ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:


       +---------------+------------------+
       |ATTRIBUTE TYPE | ATTRIBUTE VALUE  |
       +---------------+------------------+
       |Availability   | web/curl         |
       +---------------+------------------+
       |Stability      | Uncommitted      |
       +---------------+------------------+

SEE ALSO
       CURLOPT_MIMEPOST(3), CURLOPT_HTTPPOST(3)



NOTES
       Source  code  for open source software components in Oracle Solaris can
       be found at https://www.oracle.com/downloads/opensource/solaris-source-
       code-downloads.html.

       This     software     was    built    from    source    available    at
       https://github.com/oracle/solaris-userland.   The  original   community
       source       was       downloaded      from       https://curl.se/down-
       load/curl-7.83.1.tar.bz2.

       Further information about this software can be found on the open source
       community website at http://curl.haxx.se/.



libcurl 7.83.1                 November 26, 2021       CURLOPT_MIME_OPTIONS(3)