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