1CURLOPT_COPYPOSTFIELDS(3)  curl_easy_setopt options  CURLOPT_COPYPOSTFIELDS(3)
2
3
4

NAME

6       CURLOPT_COPYPOSTFIELDS - have libcurl copy data to POST
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode  curl_easy_setopt(CURL  *handle,  CURLOPT_COPYPOSTFIELDS, char
12       *data);
13

DESCRIPTION

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 zero 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),
26       unless   another   CURLOPT_POSTFIELDS(3)  or  CURLOPT_COPYPOSTFIELDS(3)
27       option is issued.
28

DEFAULT

30       NULL
31

PROTOCOLS

33       HTTP(S)
34

EXAMPLE

36       CURL *curl = curl_easy_init();
37       if(curl) {
38         char local_buffer[1024]="data to send";
39         curl_easy_setopt(curl, CURLOPT_URL, "http://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

AVAILABILITY

51       Added in 7.17.1
52

RETURN VALUE

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

SEE ALSO

58       CURLOPT_POSTFIELDS(3), CURLOPT_POSTFIELDSIZE(3),
59
60
61
62libcurl 7.66.0                 February 03, 2016     CURLOPT_COPYPOSTFIELDS(3)
Impressum