Imported Upstream version 7.59.0
[platform/upstream/curl.git] / docs / libcurl / curl_formget.3
1 .\" **************************************************************************
2 .\" *                                  _   _ ____  _
3 .\" *  Project                     ___| | | |  _ \| |
4 .\" *                             / __| | | | |_) | |
5 .\" *                            | (__| |_| |  _ <| |___
6 .\" *                             \___|\___/|_| \_\_____|
7 .\" *
8 .\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
9 .\" *
10 .\" * This software is licensed as described in the file COPYING, which
11 .\" * you should have received as part of this distribution. The terms
12 .\" * are also available at https://curl.haxx.se/docs/copyright.html.
13 .\" *
14 .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 .\" * copies of the Software, and permit persons to whom the Software is
16 .\" * furnished to do so, under the terms of the COPYING file.
17 .\" *
18 .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 .\" * KIND, either express or implied.
20 .\" *
21 .\" **************************************************************************
22 .TH curl_formget 3 "September 02, 2017" "libcurl 7.59.0" "libcurl Manual"
23
24 .SH NAME
25 curl_formget - serialize a previously built multipart/formdata HTTP POST chain
26 .SH SYNOPSIS
27 .nf
28 .B #include <curl/curl.h>
29
30 int curl_formget(struct curl_httppost * form, void *userp,
31                   curl_formget_callback append );
32 .SH DESCRIPTION
33 curl_formget() is used to serialize data previously built/appended with
34 \fIcurl_formadd(3)\fP. Accepts a void pointer as second argument named
35 \fIuserp\fP which will be passed as the first argument to the
36 curl_formget_callback function.
37
38 .BI "typedef size_t (*curl_formget_callback)(void *" userp, " const char *" buf,
39 .BI " size_t " len ");"
40
41 The curl_formget_callback will be executed for each part of the HTTP POST
42 chain. The character buffer passed to the callback must not be freed. The
43 callback should return the buffer length passed to it on success.
44
45 If the \fBCURLFORM_STREAM\fP option is used in the formpost, it will prevent
46 \fIcurl_formget(3)\fP from working until you've performed the actual HTTP
47 request as only then will libcurl get the actual read callback to use!
48 .SH RETURN VALUE
49 0 means everything was ok, non-zero means an error occurred
50 .SH EXAMPLE
51 .nf
52
53  size_t print_httppost_callback(void *arg, const char *buf, size_t len)
54  {
55    fwrite(buf, len, 1, stdout);
56    (*(size_t *) arg) += len;
57    return len;
58  }
59
60  size_t print_httppost(struct curl_httppost *post)
61  {
62    size_t total_size = 0;
63    if(curl_formget(post, &total_size, print_httppost_callback)) {
64      return (size_t) -1;
65    }
66    return total_size;
67  }
68 .SH AVAILABILITY
69 This function was added in libcurl 7.15.5. The form API is deprecated in
70 libcurl 7.56.0.
71 .SH "SEE ALSO"
72 .BR curl_formadd "(3), " curl_mime_init "(3)"