quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

CURLOPT_COPYPOSTFIELDS.md (2199B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: CURLOPT_COPYPOSTFIELDS
      5 Section: 3
      6 Source: libcurl
      7 See-also:
      8   - CURLOPT_MIMEPOST (3)
      9   - CURLOPT_POSTFIELDS (3)
     10   - CURLOPT_POSTFIELDSIZE (3)
     11   - CURLOPT_UPLOAD (3)
     12 Protocol:
     13   - HTTP
     14 Added-in: 7.17.1
     15 ---
     16 
     17 # NAME
     18 
     19 CURLOPT_COPYPOSTFIELDS - have libcurl copy data to POST
     20 
     21 # SYNOPSIS
     22 
     23 ~~~c
     24 #include <curl/curl.h>
     25 
     26 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COPYPOSTFIELDS, char *data);
     27 ~~~
     28 
     29 # DESCRIPTION
     30 
     31 Pass a char pointer as parameter, which should be the full *data* to post in a
     32 HTTP POST operation. It behaves as the CURLOPT_POSTFIELDS(3) option, but the
     33 original data is instead copied by the library, allowing the application to
     34 overwrite the original data after setting this option.
     35 
     36 Because data is copied, care must be taken when using this option in
     37 conjunction with CURLOPT_POSTFIELDSIZE(3) or CURLOPT_POSTFIELDSIZE_LARGE(3).
     38 If the size has not been set prior to CURLOPT_COPYPOSTFIELDS(3), the data is
     39 assumed to be a null-terminated string; else the stored size informs the
     40 library about the byte count to copy. In any case, the size must not be
     41 changed after CURLOPT_COPYPOSTFIELDS(3), unless another CURLOPT_POSTFIELDS(3)
     42 or CURLOPT_COPYPOSTFIELDS(3) option is set.
     43 
     44 The application does not have to keep the string around after setting this
     45 option.
     46 
     47 Using this option multiple times makes the last set string override the
     48 previous ones. Set it to NULL to disable its use again.
     49 
     50 # DEFAULT
     51 
     52 NULL
     53 
     54 # %PROTOCOLS%
     55 
     56 # EXAMPLE
     57 
     58 ~~~c
     59 int main(void)
     60 {
     61   CURL *curl = curl_easy_init();
     62   if(curl) {
     63     char local_buffer[1024]="data to send";
     64     curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
     65 
     66     /* size of the data to copy from the buffer and send in the request */
     67     curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 12L);
     68 
     69     /* send data from the local stack */
     70     curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, local_buffer);
     71 
     72     curl_easy_perform(curl);
     73   }
     74 }
     75 ~~~
     76 
     77 # %AVAILABILITY%
     78 
     79 # RETURN VALUE
     80 
     81 curl_easy_setopt(3) returns a CURLcode indicating success or error.
     82 
     83 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
     84 libcurl-errors(3).