CURLOPT_POSTFIELDSIZE.3 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. .\" generated by cd2nroff 0.1 from CURLOPT_POSTFIELDSIZE.md
  2. .TH CURLOPT_POSTFIELDSIZE 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_POSTFIELDSIZE \- size of POST data pointed to
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POSTFIELDSIZE, long size);
  9. .fi
  10. .SH DESCRIPTION
  11. If you want to post static data to the server without having libcurl do a
  12. strlen() to measure the data size, this option must be used. When this option
  13. is used you can post fully binary data, which otherwise is likely to fail. If
  14. this size is set to \-1, libcurl uses strlen() to get the size or relies on the
  15. \fICURLOPT_READFUNCTION(3)\fP (if used) to signal the end of data.
  16. If you post more than 2GB, use \fICURLOPT_POSTFIELDSIZE_LARGE(3)\fP.
  17. .SH DEFAULT
  18. -1
  19. .SH PROTOCOLS
  20. This functionality affects http only
  21. .SH EXAMPLE
  22. .nf
  23. #include <string.h> /* for strlen */
  24. int main(void)
  25. {
  26. CURL *curl = curl_easy_init();
  27. if(curl) {
  28. const char *data = "data to send";
  29. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  30. /* size of the POST data */
  31. curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) strlen(data));
  32. curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
  33. curl_easy_perform(curl);
  34. }
  35. }
  36. .fi
  37. .SH AVAILABILITY
  38. Added in curl 7.2
  39. .SH RETURN VALUE
  40. Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
  41. .SH SEE ALSO
  42. .BR CURLOPT_POSTFIELDS (3),
  43. .BR CURLOPT_POSTFIELDSIZE_LARGE (3)