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