curl_formget.3 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. .\" generated by cd2nroff 0.1 from curl_formget.md
  2. .TH curl_formget 3 "2025-01-17" libcurl
  3. .SH NAME
  4. curl_formget \- serialize a multipart form POST chain
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. int curl_formget(struct curl_httppost * form, void *userp,
  9. curl_formget_callback append);
  10. .fi
  11. .SH DESCRIPTION
  12. The form API (including this function) is deprecated since libcurl 7.56.0.
  13. curl_formget() serializes data previously built with \fIcurl_formadd(3)\fP. It
  14. accepts a void pointer as second argument named \fIuserp\fP which is passed as the
  15. first argument to the curl_formget_callback function.
  16. .nf
  17. typedef size_t (*curl_formget_callback)(void *userp, const char *buf,
  18. size_t len);"
  19. .fi
  20. The curl_formget_callback is invoked for each part of the HTTP POST chain. The
  21. character buffer passed to the callback must not be freed. The callback should
  22. return the buffer length passed to it on success.
  23. If the \fBCURLFORM_STREAM\fP option is used in the formpost, it prevents
  24. \fIcurl_formget(3)\fP from working until you have performed the actual HTTP request.
  25. This, because first then does libcurl known which actual read callback to use!
  26. .SH PROTOCOLS
  27. This functionality affects http only
  28. .SH EXAMPLE
  29. .nf
  30. size_t print_httppost_callback(void *arg, const char *buf, size_t len)
  31. {
  32. fwrite(buf, len, 1, stdout);
  33. (*(size_t *) arg) += len;
  34. return len;
  35. }
  36. size_t print_httppost(struct curl_httppost *post)
  37. {
  38. size_t total_size = 0;
  39. if(curl_formget(post, &total_size, print_httppost_callback)) {
  40. return (size_t) -1;
  41. }
  42. return total_size;
  43. }
  44. .fi
  45. .SH AVAILABILITY
  46. Added in curl 7.15.5
  47. .SH RETURN VALUE
  48. 0 means everything was OK, non\-zero means an error occurred
  49. .SH SEE ALSO
  50. .BR curl_formadd (3),
  51. .BR curl_mime_init (3)