CURLOPT_MIME_OPTIONS.3 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. .\" generated by cd2nroff 0.1 from CURLOPT_MIME_OPTIONS.md
  2. .TH CURLOPT_MIME_OPTIONS 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_MIME_OPTIONS \- set MIME option flags
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIME_OPTIONS, long options);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long that holds a bitmask of CURLMIMEOPT_* defines. Each bit is a
  12. Boolean flag used while encoding a MIME tree or multipart form data.
  13. Available bits are:
  14. .IP CURLMIMEOPT_FORMESCAPE
  15. Tells libcurl to escape multipart form field and filenames using the
  16. backslash\-escaping algorithm rather than percent\-encoding (HTTP only).
  17. Backslash\-escaping consists in preceding backslashes and double quotes with
  18. a backslash. Percent encoding maps all occurrences of double quote,
  19. carriage return and line feed to %22, %0D and %0A respectively.
  20. Before version 7.81.0, percent\-encoding was never applied.
  21. HTTP browsers used to do backslash\-escaping in the past but have over time
  22. transitioned to use percent\-encoding. This option allows one to address
  23. server\-side applications that have not yet have been converted.
  24. As an example, consider field or filename \fIstrangename"kind\fP. When the
  25. containing multipart form is sent, this is normally transmitted as
  26. \fIstrangename%22kind\fP. When this option is set, it is sent as
  27. \fIstrangename"kind\fP.
  28. .SH DEFAULT
  29. 0, meaning disabled.
  30. .SH PROTOCOLS
  31. This functionality affects http, imap and smtp
  32. .SH EXAMPLE
  33. .nf
  34. int main(void)
  35. {
  36. CURL *curl = curl_easy_init();
  37. curl_mime *form = NULL;
  38. if(curl) {
  39. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  40. curl_easy_setopt(curl, CURLOPT_MIME_OPTIONS, CURLMIMEOPT_FORMESCAPE);
  41. form = curl_mime_init(curl);
  42. if(form) {
  43. curl_mimepart *part = curl_mime_addpart(form);
  44. if(part) {
  45. curl_mime_filedata(part, "strange\\\\file\\\\name");
  46. curl_mime_name(part, "strange\\"field\\"name");
  47. curl_easy_setopt(curl, CURLOPT_MIMEPOST, form);
  48. /* Perform the request */
  49. curl_easy_perform(curl);
  50. }
  51. }
  52. curl_easy_cleanup(curl);
  53. curl_mime_free(form);
  54. }
  55. }
  56. .fi
  57. .SH AVAILABILITY
  58. Added in curl 7.81.0
  59. .SH RETURN VALUE
  60. Returns CURLE_OK
  61. .SH SEE ALSO
  62. .BR CURLOPT_HTTPPOST (3),
  63. .BR CURLOPT_MIMEPOST (3)