1CURLOPT_POSTFIELDSIZE(3) curl_easy_setopt options CURLOPT_POSTFIELDSIZE(3)
2
3
4
6 CURLOPT_POSTFIELDSIZE - size of POST data pointed to
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POSTFIELDSIZE, long size);
12
14 If you want to post data to the server without having libcurl do a
15 strlen() to measure the data size, this option must be used. When this
16 option is used you can post fully binary data, which otherwise is
17 likely to fail. If this size is set to -1, the library will use
18 strlen() to get the size.
19
20 If you post more than 2GB, use CURLOPT_POSTFIELDSIZE_LARGE(3).
21
23 -1
24
26 HTTP
27
29 CURL *curl = curl_easy_init();
30 if(curl) {
31 const char *data = "data to send";
32
33 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
34
35 /* size of the POST data */
36 curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) strlen(data));
37
38 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
39
40 curl_easy_perform(curl);
41 }
42
44 Along with HTTP
45
47 Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
48
50 CURLOPT_POSTFIELDS(3), CURLOPT_POSTFIELDSIZE_LARGE(3),
51
52
53
54libcurl 7.85.0 May 17, 2022 CURLOPT_POSTFIELDSIZE(3)