1CURLOPT_COPYPOSTFIELDS(3) curl_easy_setopt options CURLOPT_COPYPOSTFIELDS(3)
2
3
4
6 CURLOPT_COPYPOSTFIELDS - have libcurl copy data to POST
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COPYPOSTFIELDS, char
12 *data);
13
15 Pass a char * as parameter, which should be the full data to post in a
16 HTTP POST operation. It behaves as the CURLOPT_POSTFIELDS(3) option,
17 but the original data is instead copied by the library, allowing the
18 application to overwrite the original data after setting this option.
19
20 Because data are copied, care must be taken when using this option in
21 conjunction with CURLOPT_POSTFIELDSIZE(3) or CURLOPT_POSTFIELD‐
22 SIZE_LARGE(3): If the size has not been set prior to CURLOPT_COPYPOST‐
23 FIELDS(3), the data is assumed to be a null-terminated string; else the
24 stored size informs the library about the byte count to copy. In any
25 case, the size must not be changed after CURLOPT_COPYPOSTFIELDS(3), un‐
26 less another CURLOPT_POSTFIELDS(3) or CURLOPT_COPYPOSTFIELDS(3) option
27 is issued.
28
30 NULL
31
33 HTTP(S)
34
36 CURL *curl = curl_easy_init();
37 if(curl) {
38 char local_buffer[1024]="data to send";
39 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
40
41 /* size of the data to copy from the buffer and send in the request */
42 curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 12L);
43
44 /* send data from the local stack */
45 curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, local_buffer);
46
47 curl_easy_perform(curl);
48 }
49
51 Added in 7.17.1
52
54 Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if
55 not, or CURLE_OUT_OF_MEMORY if there was insufficient heap space.
56
58 CURLOPT_POSTFIELDS(3), CURLOPT_POSTFIELDSIZE(3),
59
60
61
62libcurl 7.79.1 November 04, 2020 CURLOPT_COPYPOSTFIELDS(3)