curl_pushheader_bynum.3 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 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. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .TH curl_pushheader_bynum 3 "9 Jun 2023" "libcurl" "libcurl"
  25. .SH NAME
  26. curl_pushheader_bynum - get a push header by index
  27. .SH SYNOPSIS
  28. .nf
  29. #include <curl/curl.h>
  30. char *curl_pushheader_bynum(struct curl_pushheaders *h, size_t num);
  31. .fi
  32. .SH DESCRIPTION
  33. This is a function that is only functional within a
  34. \fICURLMOPT_PUSHFUNCTION(3)\fP callback. It makes no sense to try to use it
  35. elsewhere and it has no function then.
  36. It returns the value for the header field at the given index \fBnum\fP, for
  37. the incoming server push request or NULL. The data pointed will be freed when
  38. this callback returns. The returned pointer points to a "name:value" string
  39. that will be freed when this callback returns.
  40. .SH EXAMPLE
  41. .nf
  42. /* output all the incoming push request headers */
  43. int curl_push_callback(CURL *parent,
  44. CURL *easy,
  45. size_t num_headers,
  46. struct curl_pushheaders *headers,
  47. void *clientp)
  48. {
  49. sizt_t i = 0;
  50. char *field;
  51. do {
  52. field = curl_pushheader_bynum(headers, i);
  53. if(field)
  54. fprintf(stderr, "Push header: %s\\n", field);
  55. i++;
  56. } while(field);
  57. return CURL_PUSH_OK; /* permission granted */
  58. }
  59. curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, curl_push_callback);
  60. .fi
  61. .SH AVAILABILITY
  62. Added in 7.44.0
  63. .SH RETURN VALUE
  64. Returns a pointer to the header field content or NULL.
  65. .SH "SEE ALSO"
  66. .BR CURLMOPT_PUSHFUNCTION "(3)," curl_pushheader_byname "(3),"