quickjs-tart

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

curl_formget.md (1797B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: curl_formget
      5 Section: 3
      6 Source: libcurl
      7 See-also:
      8   - curl_formadd (3)
      9   - curl_mime_init (3)
     10 Protocol:
     11   - HTTP
     12 Added-in: 7.15.5
     13 ---
     14 
     15 # NAME
     16 
     17 curl_formget - serialize a multipart form POST chain
     18 
     19 # SYNOPSIS
     20 
     21 ~~~c
     22 #include <curl/curl.h>
     23 
     24 int curl_formget(struct curl_httppost * form, void *userp,
     25                  curl_formget_callback append);
     26 ~~~
     27 
     28 # DESCRIPTION
     29 
     30 The form API (including this function) is deprecated since libcurl 7.56.0.
     31 
     32 curl_formget() serializes data previously built with curl_formadd(3). It
     33 accepts a void pointer as second argument named *userp* which is passed as the
     34 first argument to the curl_formget_callback function.
     35 
     36 ~~~c
     37  typedef size_t (*curl_formget_callback)(void *userp, const char *buf,
     38                                          size_t len);"
     39 ~~~
     40 
     41 The *curl_formget_callback* is invoked for each part of the HTTP POST chain.
     42 The character buffer passed to the callback must not be freed. The callback
     43 should return the buffer length passed to it on success.
     44 
     45 If the **CURLFORM_STREAM** option is used in the formpost, it prevents
     46 curl_formget(3) from working until you have performed the actual HTTP request.
     47 This, because first then does libcurl known which actual read callback to use.
     48 
     49 # %PROTOCOLS%
     50 
     51 # EXAMPLE
     52 
     53 ~~~c
     54 size_t print_httppost_callback(void *arg, const char *buf, size_t len)
     55 {
     56   fwrite(buf, len, 1, stdout);
     57   (*(size_t *) arg) += len;
     58   return len;
     59 }
     60 
     61 size_t print_httppost(struct curl_httppost *post)
     62 {
     63   size_t total_size = 0;
     64   if(curl_formget(post, &total_size, print_httppost_callback)) {
     65     return (size_t) -1;
     66   }
     67   return total_size;
     68 }
     69 ~~~
     70 
     71 # %AVAILABILITY%
     72 
     73 # RETURN VALUE
     74 
     75 0 means everything was OK, non-zero means an error occurred