quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

CURLOPT_MIME_OPTIONS.md (2410B)


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