CURLOPT_MIME_OPTIONS.3 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 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. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH CURLOPT_MIME_OPTIONS 3 "January 02, 2023" "libcurl 7.88.1" "curl_easy_setopt options"
  26. .SH NAME
  27. CURLOPT_MIME_OPTIONS \- set MIME option flags
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIME_OPTIONS, long options);
  32. .fi
  33. .SH DESCRIPTION
  34. Pass a long that holds a bitmask of CURLMIMEOPT_* defines. Each bit is a
  35. Boolean flag used while encoding a MIME tree or multipart form data.
  36. Available bits are:
  37. .IP CURLMIMEOPT_FORMESCAPE
  38. Tells libcurl to escape multipart form field and file names using the
  39. backslash-escaping algorithm rather than percent-encoding (HTTP only).
  40. Backslash-escaping consists in preceding backslashes and double quotes with
  41. a backslash. Percent encoding maps all occurrences of double quote,
  42. carriage return and line feed to %22, %0D and %0A respectively.
  43. Before version 7.81.0, percent-encoding was never applied.
  44. HTTP browsers used to do backslash-escaping in the past but have over time
  45. transitioned to use percent-encoding. This option allows one to address
  46. server-side applications that have not yet have been converted.
  47. As an example, consider field or file name \fIstrange\\name"kind\fP.
  48. When the containing multipart form is sent, this is normally transmitted as
  49. \fIstrange\\name%22kind\fP. When this option is set, it is sent as
  50. \fIstrange\\\\name\\"kind\fP.
  51. .SH DEFAULT
  52. 0, meaning disabled.
  53. .SH PROTOCOLS
  54. HTTP, IMAP, SMTP
  55. .SH EXAMPLE
  56. .nf
  57. CURL *curl = curl_easy_init();
  58. curl_mime *form = NULL;
  59. if(curl) {
  60. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  61. curl_easy_setopt(curl, CURLOPT_MIME_OPTIONS, CURLMIMEOPT_FORMESCAPE);
  62. form = curl_mime_init(curl);
  63. if(form) {
  64. curl_mimepart *part = curl_mime_addpart(form);
  65. if(part) {
  66. curl_mime_filedata(part, "strange\\\\file\\\\name");
  67. curl_mime_name(part, "strange\\"field\\"name");
  68. curl_easy_setopt(curl, CURLOPT_MIMEPOST, form);
  69. /* Perform the request */
  70. curl_easy_perform(curl);
  71. }
  72. }
  73. curl_easy_cleanup(curl);
  74. curl_mime_free(mime);
  75. }
  76. .fi
  77. .SH AVAILABILITY
  78. Option added in 7.81.0.
  79. .SH RETURN VALUE
  80. Returns CURLE_OK
  81. .SH "SEE ALSO"
  82. .BR CURLOPT_MIMEPOST "(3), " CURLOPT_HTTPPOST "(3)"