curl_pushheader_bynum.3 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. .\" generated by cd2nroff 0.1 from curl_pushheader_bynum.md
  2. .TH curl_pushheader_bynum 3 "2025-01-17" libcurl
  3. .SH NAME
  4. curl_pushheader_bynum \- get a push header by index
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. char *curl_pushheader_bynum(struct curl_pushheaders *h, size_t num);
  9. .fi
  10. .SH DESCRIPTION
  11. This is a function that is only functional within a
  12. \fICURLMOPT_PUSHFUNCTION(3)\fP callback. It makes no sense to try to use it
  13. elsewhere and it has no function then.
  14. It returns the value for the header field at the given index \fBnum\fP, for
  15. the incoming server push request or NULL. The data pointed to is freed by
  16. libcurl when this callback returns. The returned pointer points to a
  17. \&"name:value" string that gets freed when this callback returns.
  18. .SH PROTOCOLS
  19. This functionality affects http only
  20. .SH EXAMPLE
  21. .nf
  22. /* output all the incoming push request headers */
  23. static int push_cb(CURL *parent,
  24. CURL *easy,
  25. size_t num_headers,
  26. struct curl_pushheaders *headers,
  27. void *clientp)
  28. {
  29. int i = 0;
  30. char *field;
  31. do {
  32. field = curl_pushheader_bynum(headers, i);
  33. if(field)
  34. fprintf(stderr, "Push header: %s\\n", field);
  35. i++;
  36. } while(field);
  37. return CURL_PUSH_OK; /* permission granted */
  38. }
  39. int main(void)
  40. {
  41. CURLM *multi = curl_multi_init();
  42. curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, push_cb);
  43. }
  44. .fi
  45. .SH AVAILABILITY
  46. Added in curl 7.44.0
  47. .SH RETURN VALUE
  48. Returns a pointer to the header field content or NULL.
  49. .SH SEE ALSO
  50. .BR CURLMOPT_PUSHFUNCTION (3),
  51. .BR curl_pushheader_byname (3)