1curl_pushheader_byname(3)           libcurl          curl_pushheader_byname(3)
2
3
4

NAME

6       curl_pushheader_byname - get a push header by name
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       char *curl_pushheader_byname(struct curl_pushheaders *h, const char *name);
12

DESCRIPTION

14       This  is a function that is only functional within a CURLMOPT_PUSHFUNC‐
15       TION(3) callback. It makes no sense to try to use it elsewhere  and  it
16       has no function then.
17
18       It  returns the value for the given header field name (or NULL) for the
19       incoming server push request. This is a shortcut so that  the  applica‐
20       tion  does  not  have to loop through all headers to find the one it is
21       interested in. The data this function points to will be freed when this
22       callback returns. If more than one header field use the same name, this
23       returns only the first one.
24
25

EXAMPLE

27       int curl_push_callback(CURL *parent,
28                              CURL *easy,
29                              size_t num_headers,
30                              struct curl_pushheaders *headers,
31                              void *clientp)
32       {
33         char *headp;
34         int *transfers = (int *)clientp;
35         FILE *out;
36         headp = curl_pushheader_byname(headers, ":path");
37         if(headp && !strncmp(headp, "/push-", 6)) {
38           fprintf(stderr, "The PATH is %s\n", headp);
39
40           /* save the push here */
41           out = fopen("pushed-stream", "wb");
42
43           /* write to this file */
44           curl_easy_setopt(easy, CURLOPT_WRITEDATA, out);
45
46           (*transfers)++; /* one more */
47
48           return CURL_PUSH_OK;
49         }
50         return CURL_PUSH_DENY;
51       }
52
53       curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, curl_push_callback);
54       curl_multi_setopt(multi, CURLMOPT_PUSHDATA, &counter);
55

AVAILABILITY

57       Added in 7.44.0
58

RETURN VALUE

60       Returns a pointer to the header field content or NULL.
61

SEE ALSO

63       CURLMOPT_PUSHFUNCTION(3),curl_pushheader_bynum(3),
64
65
66
67libcurl 8.2.1                    June 09, 2023       curl_pushheader_byname(3)
Impressum