CURLMOPT_PUSHDATA.3 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. .\" generated by cd2nroff 0.1 from CURLMOPT_PUSHDATA.md
  2. .TH CURLMOPT_PUSHDATA 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLMOPT_PUSHDATA \- pointer to pass to push callback
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_PUSHDATA, void *pointer);
  9. .fi
  10. .SH DESCRIPTION
  11. Set a \fIpointer\fP to pass as the last argument to the
  12. \fICURLMOPT_PUSHFUNCTION(3)\fP callback. The pointer is not touched or used by
  13. libcurl itself, only passed on to the callback function.
  14. .SH DEFAULT
  15. NULL
  16. .SH PROTOCOLS
  17. This functionality affects http only
  18. .SH EXAMPLE
  19. .nf
  20. #include <string.h>
  21. /* only allow pushes for filenames starting with "push-" */
  22. int push_callback(CURL *parent,
  23. CURL *easy,
  24. size_t num_headers,
  25. struct curl_pushheaders *headers,
  26. void *clientp)
  27. {
  28. char *headp;
  29. int *transfers = (int *)clientp;
  30. FILE *out;
  31. headp = curl_pushheader_byname(headers, ":path");
  32. if(headp && !strncmp(headp, "/push-", 6)) {
  33. fprintf(stderr, "The PATH is %s\\n", headp);
  34. /* save the push here */
  35. out = fopen("pushed-stream", "wb");
  36. /* write to this file */
  37. curl_easy_setopt(easy, CURLOPT_WRITEDATA, out);
  38. (*transfers)++; /* one more */
  39. return CURL_PUSH_OK;
  40. }
  41. return CURL_PUSH_DENY;
  42. }
  43. int main(void)
  44. {
  45. int counter;
  46. CURLM *multi = curl_multi_init();
  47. curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, push_callback);
  48. curl_multi_setopt(multi, CURLMOPT_PUSHDATA, &counter);
  49. }
  50. .fi
  51. .SH AVAILABILITY
  52. Added in curl 7.44.0
  53. .SH RETURN VALUE
  54. Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not.
  55. .SH SEE ALSO
  56. .BR CURLMOPT_PIPELINING (3),
  57. .BR CURLMOPT_PUSHFUNCTION (3),
  58. .BR CURLOPT_PIPEWAIT (3),
  59. .BR RFC 7540