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