1CURLOPT_POSTFIELDSIZE(3) libcurl 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 static data to the server without having libcurl do
15 a strlen() to measure the data size, this option must be used. When
16 this 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 or rely on the CURLOPT_READFUNCTION (if used)
19 to signal the end of data.
20
21 If you post more than 2GB, use CURLOPT_POSTFIELDSIZE_LARGE(3).
22
24 -1
25
27 HTTP
28
30 CURL *curl = curl_easy_init();
31 if(curl) {
32 const char *data = "data to send";
33
34 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
35
36 /* size of the POST data */
37 curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) strlen(data));
38
39 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
40
41 curl_easy_perform(curl);
42 }
43
45 Along with HTTP
46
48 Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
49
51 CURLOPT_POSTFIELDS(3), CURLOPT_POSTFIELDSIZE_LARGE(3),
52
53
54
55ibcurl 8.2.1 April 26, 2023 CURLOPT_POSTFIELDSIZE(3)