quickjs-tart

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

CURLINFO_COOKIELIST.md (2024B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: CURLINFO_COOKIELIST
      5 Section: 3
      6 Source: libcurl
      7 See-also:
      8   - CURLOPT_COOKIELIST (3)
      9   - curl_easy_getinfo (3)
     10   - curl_easy_setopt (3)
     11 Protocol:
     12   - HTTP
     13 Added-in: 7.14.1
     14 ---
     15 
     16 # NAME
     17 
     18 CURLINFO_COOKIELIST - get all known cookies
     19 
     20 # SYNOPSIS
     21 
     22 ~~~c
     23 #include <curl/curl.h>
     24 
     25 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_COOKIELIST,
     26                            struct curl_slist **cookies);
     27 ~~~
     28 
     29 # DESCRIPTION
     30 
     31 Pass a pointer to a 'struct curl_slist *' to receive a linked-list of all
     32 cookies curl knows (expired ones, too). Do not forget to call
     33 curl_slist_free_all(3) on the list after it has been used. If there are no
     34 cookies (cookies for the handle have not been enabled or simply none have been
     35 received) the 'struct curl_slist *' is made a NULL pointer.
     36 
     37 Since 7.43.0 cookies that were imported in the Set-Cookie format without a
     38 domain name are not exported by this option.
     39 
     40 # %PROTOCOLS%
     41 
     42 # EXAMPLE
     43 
     44 ~~~c
     45 int main(void)
     46 {
     47   CURL *curl = curl_easy_init();
     48   if(curl) {
     49     CURLcode res;
     50     curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
     51 
     52     /* enable the cookie engine */
     53     curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
     54 
     55     res = curl_easy_perform(curl);
     56 
     57     if(!res) {
     58       /* extract all known cookies */
     59       struct curl_slist *cookies = NULL;
     60       res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
     61       if(!res && cookies) {
     62         /* a linked list of cookies in cookie file format */
     63         struct curl_slist *each = cookies;
     64         while(each) {
     65           printf("%s\n", each->data);
     66           each = each->next;
     67         }
     68         /* we must free these cookies when we are done */
     69         curl_slist_free_all(cookies);
     70       }
     71     }
     72     curl_easy_cleanup(curl);
     73   }
     74 }
     75 ~~~
     76 
     77 # %AVAILABILITY%
     78 
     79 # RETURN VALUE
     80 
     81 curl_easy_getinfo(3) returns a CURLcode indicating success or error.
     82 
     83 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
     84 libcurl-errors(3).