CURLOPT_COPYPOSTFIELDS.3 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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_COPYPOSTFIELDS 3 "19 Jun 2014" libcurl libcurl
  26. .SH NAME
  27. CURLOPT_COPYPOSTFIELDS \- have libcurl copy data to POST
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COPYPOSTFIELDS, char *data);
  32. .fi
  33. .SH DESCRIPTION
  34. Pass a char * as parameter, which should be the full \fIdata\fP to post in a
  35. HTTP POST operation. It behaves as the \fICURLOPT_POSTFIELDS(3)\fP option, but
  36. the original data is instead copied by the library, allowing the application
  37. to overwrite the original data after setting this option.
  38. Because data are copied, care must be taken when using this option in
  39. conjunction with \fICURLOPT_POSTFIELDSIZE(3)\fP or
  40. \fICURLOPT_POSTFIELDSIZE_LARGE(3)\fP: If the size has not been set prior to
  41. \fICURLOPT_COPYPOSTFIELDS(3)\fP, the data is assumed to be a null-terminated
  42. string; else the stored size informs the library about the byte count to
  43. copy. In any case, the size must not be changed after
  44. \fICURLOPT_COPYPOSTFIELDS(3)\fP, unless another \fICURLOPT_POSTFIELDS(3)\fP or
  45. \fICURLOPT_COPYPOSTFIELDS(3)\fP option is issued.
  46. .SH DEFAULT
  47. NULL
  48. .SH PROTOCOLS
  49. HTTP(S)
  50. .SH EXAMPLE
  51. .nf
  52. CURL *curl = curl_easy_init();
  53. if(curl) {
  54. char local_buffer[1024]="data to send";
  55. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  56. /* size of the data to copy from the buffer and send in the request */
  57. curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 12L);
  58. /* send data from the local stack */
  59. curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, local_buffer);
  60. curl_easy_perform(curl);
  61. }
  62. .fi
  63. .SH AVAILABILITY
  64. Added in 7.17.1
  65. .SH RETURN VALUE
  66. Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
  67. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  68. .SH "SEE ALSO"
  69. .BR CURLOPT_POSTFIELDS "(3), " CURLOPT_POSTFIELDSIZE "(3), "