CURLOPT_MIME_OPTIONS.3 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" **************************************************************************
  22. .\"
  23. .TH CURLOPT_MIME_OPTIONS 3 "2 Oct 2021" "libcurl 7.81.0" "curl_easy_setopt options"
  24. .SH NAME
  25. CURLOPT_MIME_OPTIONS \- set MIME option flags
  26. .SH SYNOPSIS
  27. .nf
  28. #include <curl/curl.h>
  29. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIME_OPTIONS, long options);
  30. .fi
  31. .SH DESCRIPTION
  32. Pass a long that holds a bitmask of CURLMIMEOPT_* defines. Each bit is a
  33. Boolean flag used while encoding a MIME tree or multipart form data.
  34. Available bits are:
  35. .IP CURLMIMEOPT_FORMESCAPE
  36. Tells libcurl to escape multipart form field and file names using the
  37. backslash-escaping algorithm rather than percent-encoding (HTTP only).
  38. Backslash-escaping consists in preceding backslashes and double quotes with
  39. a backslash. Percent encoding maps all occurrences of double quote,
  40. carriage return and line feed to %22, %0D and %0A respectively.
  41. Before version 7.81.0, percent-encoding was never applied.
  42. HTTP browsers used to do backslash-escaping in the past but have over time
  43. transitioned to use percent-encoding. This option allows to address
  44. server-side applications that have not yet have been converted.
  45. As an example, consider field or file name \fIstrange\\name"kind\fP.
  46. When the containing multipart form is sent, this is normally transmitted as
  47. \fIstrange\\name%22kind\fP. When this option is set, it is sent as
  48. \fIstrange\\\\name\\"kind\fP.
  49. .SH DEFAULT
  50. 0, meaning disabled.
  51. .SH PROTOCOLS
  52. HTTP, IMAP, SMTP
  53. .SH EXAMPLE
  54. .nf
  55. CURL *curl = curl_easy_init();
  56. curl_mime *form = NULL;
  57. if(curl) {
  58. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  59. curl_easy_setopt(curl, CURLOPT_MIME_OPTIONS, CURLMIMEOPT_FORMESCAPE);
  60. form = curl_mime_init(curl);
  61. if(form) {
  62. curl_mimepart *part = curl_mime_addpart(form);
  63. if(part) {
  64. curl_mime_filedata(part, "strange\\\\file\\\\name");
  65. curl_mime_name(part, "strange\\"field\\"name");
  66. curl_easy_setopt(curl, CURLOPT_MIMEPOST, form);
  67. /* Perform the request */
  68. curl_easy_perform(curl);
  69. }
  70. }
  71. curl_easy_cleanup(curl);
  72. curl_mime_free(mime);
  73. }
  74. .fi
  75. .SH AVAILABILITY
  76. Option added in 7.81.0.
  77. .SH RETURN VALUE
  78. Returns CURLE_OK
  79. .SH "SEE ALSO"
  80. .BR CURLOPT_MIMEPOST "(3), " CURLOPT_HTTPPOST "(3)"