CURLMOPT_PUSHDATA.3 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" **************************************************************************
  22. .\"
  23. .TH CURLMOPT_PUSHDATA 3 "1 Jun 2015" "libcurl 7.44.0" "curl_multi_setopt options"
  24. .SH NAME
  25. CURLMOPT_PUSHDATA \- pointer to pass to push callback
  26. .SH SYNOPSIS
  27. .nf
  28. #include <curl/curl.h>
  29. CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_PUSHDATA, void *pointer);
  30. .fi
  31. .SH DESCRIPTION
  32. Set \fIpointer\fP to pass as the last argument to the
  33. \fICURLMOPT_PUSHFUNCTION(3)\fP callback. The pointer will not be touched or
  34. used by libcurl itself, only passed on to the callback function.
  35. .SH DEFAULT
  36. NULL
  37. .SH PROTOCOLS
  38. HTTP(S)
  39. .SH EXAMPLE
  40. .nf
  41. /* only allow pushes for file names starting with "push-" */
  42. int push_callback(CURL *parent,
  43. CURL *easy,
  44. size_t num_headers,
  45. struct curl_pushheaders *headers,
  46. void *userp)
  47. {
  48. char *headp;
  49. int *transfers = (int *)userp;
  50. FILE *out;
  51. headp = curl_pushheader_byname(headers, ":path");
  52. if(headp && !strncmp(headp, "/push-", 6)) {
  53. fprintf(stderr, "The PATH is %s\\n", headp);
  54. /* save the push here */
  55. out = fopen("pushed-stream", "wb");
  56. /* write to this file */
  57. curl_easy_setopt(easy, CURLOPT_WRITEDATA, out);
  58. (*transfers)++; /* one more */
  59. return CURL_PUSH_OK;
  60. }
  61. return CURL_PUSH_DENY;
  62. }
  63. curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, push_callback);
  64. curl_multi_setopt(multi, CURLMOPT_PUSHDATA, &counter);
  65. .fi
  66. .SH AVAILABILITY
  67. Added in 7.44.0
  68. .SH RETURN VALUE
  69. Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not.
  70. .SH "SEE ALSO"
  71. .BR CURLMOPT_PUSHFUNCTION "(3), " CURLMOPT_PIPELINING "(3), "
  72. .BR CURLOPT_PIPEWAIT "(3), "
  73. .BR RFC 7540