1curl_formget(3) libcurl curl_formget(3)
2
3
4
6 curl_formget - serialize a previously built multipart form POST chain
7
9 #include <curl/curl.h>
10
11 int curl_formget(struct curl_httppost * form, void *userp,
12 curl_formget_callback append );
13
15 curl_formget() is used to serialize data previously built/appended with
16 curl_formadd(3). Accepts a void pointer as second argument named userp
17 which will be passed as the first argument to the curl_formget_callback
18 function.
19
20 typedef size_t (*curl_formget_callback)(void *userp, const char *buf,
21 size_t len);
22
23 The curl_formget_callback will be executed for each part of the HTTP
24 POST chain. The character buffer passed to the callback must not be
25 freed. The callback should return the buffer length passed to it on
26 success.
27
28 If the CURLFORM_STREAM option is used in the formpost, it will prevent
29 curl_formget(3) from working until you have performed the actual HTTP
30 request as only then will libcurl get the actual read callback to use!
31
33 size_t print_httppost_callback(void *arg, const char *buf, size_t len)
34 {
35 fwrite(buf, len, 1, stdout);
36 (*(size_t *) arg) += len;
37 return len;
38 }
39
40 size_t print_httppost(struct curl_httppost *post)
41 {
42 size_t total_size = 0;
43 if(curl_formget(post, &total_size, print_httppost_callback)) {
44 return (size_t) -1;
45 }
46 return total_size;
47 }
48
50 This function was added in libcurl 7.15.5. The form API is deprecated
51 in libcurl 7.56.0.
52
54 0 means everything was OK, non-zero means an error occurred
55
57 curl_formadd(3), curl_mime_init(3)
58
59
60
61libcurl 8.2.1 April 26, 2023 curl_formget(3)