2
0

curl_pushheader_byname.3 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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_byname 3 "9 Jun 2023" "libcurl" "libcurl"
  25. .SH NAME
  26. curl_pushheader_byname - get a push header by name
  27. .SH SYNOPSIS
  28. .nf
  29. #include <curl/curl.h>
  30. char *curl_pushheader_byname(struct curl_pushheaders *h, const char *name);
  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 given header field name (or NULL) for the
  37. incoming server push request. This is a shortcut so that the application does
  38. not have to loop through all headers to find the one it is interested in. The
  39. data this function points to will be freed when this callback returns. If more
  40. than one header field use the same name, this returns only the first one.
  41. .SH EXAMPLE
  42. .nf
  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. char *headp;
  50. int *transfers = (int *)clientp;
  51. FILE *out;
  52. headp = curl_pushheader_byname(headers, ":path");
  53. if(headp && !strncmp(headp, "/push-", 6)) {
  54. fprintf(stderr, "The PATH is %s\\n", headp);
  55. /* save the push here */
  56. out = fopen("pushed-stream", "wb");
  57. /* write to this file */
  58. curl_easy_setopt(easy, CURLOPT_WRITEDATA, out);
  59. (*transfers)++; /* one more */
  60. return CURL_PUSH_OK;
  61. }
  62. return CURL_PUSH_DENY;
  63. }
  64. curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, curl_push_callback);
  65. curl_multi_setopt(multi, CURLMOPT_PUSHDATA, &counter);
  66. .fi
  67. .SH AVAILABILITY
  68. Added in 7.44.0
  69. .SH RETURN VALUE
  70. Returns a pointer to the header field content or NULL.
  71. .SH "SEE ALSO"
  72. .BR CURLMOPT_PUSHFUNCTION "(3)," curl_pushheader_bynum "(3), "