1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_pushheader_bynum
5Section: 3
6Source: libcurl
7See-also:
8  - CURLMOPT_PUSHFUNCTION (3)
9  - curl_pushheader_byname (3)
10Protocol:
11  - HTTP
12---
13
14# NAME
15
16curl_pushheader_bynum - get a push header by index
17
18# SYNOPSIS
19
20~~~c
21#include <curl/curl.h>
22
23char *curl_pushheader_bynum(struct curl_pushheaders *h, size_t num);
24~~~
25
26# DESCRIPTION
27
28This is a function that is only functional within a
29CURLMOPT_PUSHFUNCTION(3) callback. It makes no sense to try to use it
30elsewhere and it has no function then.
31
32It returns the value for the header field at the given index **num**, for
33the incoming server push request or NULL. The data pointed to is freed by
34libcurl when this callback returns. The returned pointer points to a
35"name:value" string that gets freed when this callback returns.
36
37# EXAMPLE
38
39~~~c
40/* output all the incoming push request headers */
41static int push_cb(CURL *parent,
42                   CURL *easy,
43                   size_t num_headers,
44                   struct curl_pushheaders *headers,
45                   void *clientp)
46{
47  int i = 0;
48  char *field;
49  do {
50     field = curl_pushheader_bynum(headers, i);
51     if(field)
52       fprintf(stderr, "Push header: %s\n", field);
53     i++;
54  } while(field);
55  return CURL_PUSH_OK; /* permission granted */
56}
57
58int main(void)
59{
60  CURLM *multi = curl_multi_init();
61  curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, push_cb);
62}
63~~~
64
65# AVAILABILITY
66
67Added in 7.44.0
68
69# RETURN VALUE
70
71Returns a pointer to the header field content or NULL.
72