quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

curl_pushheader_bynum.md (1607B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: curl_pushheader_bynum
      5 Section: 3
      6 Source: libcurl
      7 See-also:
      8   - CURLMOPT_PUSHFUNCTION (3)
      9   - curl_pushheader_byname (3)
     10 Protocol:
     11   - HTTP
     12 Added-in: 7.44.0
     13 ---
     14 
     15 # NAME
     16 
     17 curl_pushheader_bynum - get a push header by index
     18 
     19 # SYNOPSIS
     20 
     21 ~~~c
     22 #include <curl/curl.h>
     23 
     24 char *curl_pushheader_bynum(struct curl_pushheaders *h, size_t num);
     25 ~~~
     26 
     27 # DESCRIPTION
     28 
     29 This is a function that is only functional within a
     30 CURLMOPT_PUSHFUNCTION(3) callback. It makes no sense to try to use it
     31 elsewhere and it has no function then.
     32 
     33 It returns the value for the header field at the given index **num**, for
     34 the incoming server push request or NULL. The data pointed to is freed by
     35 libcurl 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 */
     44 static 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 
     61 int 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 
     72 Returns a pointer to the header field content or NULL.