1curl_easy_nextheader(3)             libcurl            curl_easy_nextheader(3)
2
3
4

NAME

6       curl_easy_nextheader - get the next HTTP header
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       struct curl_header *curl_easy_nextheader(CURL *easy,
12                                                unsigned int origin,
13                                                int request,
14                                                struct curl_header *prev);
15

DESCRIPTION

17       This  function lets an application iterate over all previously received
18       HTTP headers.
19
20       The origin argument is for specifying which headers to  receive,  as  a
21       single  HTTP  transfer  might  provide  headers  from several different
22       places and they may then have different  importance  to  the  user  and
23       headers  using the same name might be used. The origin is a bitmask for
24       what header sources you want. See the curl_easy_header(3) man page  for
25       the origin descriptions.
26
27       The  request argument tells libcurl from which request you want headers
28       from. A single transfer might consist of a series of HTTP requests  and
29       this  argument lets you specify which particular individual request you
30       want the headers from. 0 being the first request and  then  the  number
31       increases  for  further redirects or when multi-state authentication is
32       used. Passing in -1 is a shortcut to "the last" request in the  series,
33       independently of the actual amount of requests used.
34
35       It is suggested that you pass in the same origin and request when iter‐
36       ating over a range of headers as changing the value mid-loop might give
37       you unexpected results.
38
39       If  prev  is  NULL, this function returns a pointer to the first header
40       stored within the given scope (origin + request).
41
42       If  prev  is  a  pointer  to  a  previously  returned  header   struct,
43       curl_easy_nextheader(3) returns a pointer the next header stored within
44       the given scope. This way, an application can iterate over  all  avail‐
45       able headers.
46
47       The  memory  for  the  struct  this  points to, is owned and managed by
48       libcurl and is associated with the easy handle. Applications must  copy
49       the  data  if they want it to survive subsequent API calls or the life-
50       time of the easy handle.
51

EXAMPLE

53       struct curl_header *prev = NULL;
54       struct curl_header *h;
55
56       /* extract the normal headers from the first request */
57       while((h = curl_easy_nextheader(easy, CURLH_HEADER, 0, prev))) {
58          printf("%s: %s\n", h->name, h->value);
59          prev = h;
60       }
61
62       /* extract the normal headers + 1xx + trailers from the last request */
63       unsigned int origin = CURLH_HEADER| CURLH_1XX | CURLH_TRAILER;
64       while((h = curl_easy_nextheader(easy, origin, -1, prev))) {
65          printf("%s: %s\n", h->name, h->value);
66          prev = h;
67       }
68

AVAILABILITY

70       Added in 7.83.0. Officially supported since 7.84.0.
71

RETURN VALUE

73       This function returns the next header, or NULL when there are  no  more
74       (matching) headers or an error occurred.
75
76       If this function returns NULL when prev was set to NULL, then there are
77       no headers available within the scope to return.
78

SEE ALSO

80       curl_easy_header(3), curl_easy_perform(3)
81
82
83
84libcurl 8.2.1                    July 07, 2023         curl_easy_nextheader(3)
Impressum