quickjs-tart

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

CURLINFO_HTTPAUTH_AVAIL.md (1754B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: CURLINFO_HTTPAUTH_AVAIL
      5 Section: 3
      6 Source: libcurl
      7 See-also:
      8   - CURLINFO_PROXYAUTH_AVAIL (3)
      9   - CURLOPT_HTTPAUTH (3)
     10   - curl_easy_getinfo (3)
     11   - curl_easy_setopt (3)
     12 Protocol:
     13   - HTTP
     14 Added-in: 7.10.8
     15 ---
     16 
     17 # NAME
     18 
     19 CURLINFO_HTTPAUTH_AVAIL - get available HTTP authentication methods
     20 
     21 # SYNOPSIS
     22 
     23 ~~~c
     24 #include <curl/curl.h>
     25 
     26 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTPAUTH_AVAIL, long *authp);
     27 ~~~
     28 
     29 # DESCRIPTION
     30 
     31 Pass a pointer to a long to receive a bitmask indicating the authentication
     32 method(s) available according to the previous response. The meaning of the
     33 bits is explained in the CURLOPT_HTTPAUTH(3) option for curl_easy_setopt(3).
     34 
     35 # %PROTOCOLS%
     36 
     37 # EXAMPLE
     38 
     39 ~~~c
     40 int main(void)
     41 {
     42   CURL *curl = curl_easy_init();
     43   if(curl) {
     44     CURLcode res;
     45     curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
     46 
     47     res = curl_easy_perform(curl);
     48 
     49     if(!res) {
     50       /* extract the available authentication types */
     51       long auth;
     52       res = curl_easy_getinfo(curl, CURLINFO_HTTPAUTH_AVAIL, &auth);
     53       if(!res) {
     54         if(!auth)
     55           printf("No auth available, perhaps no 401?\n");
     56         else {
     57           printf("%s%s%s%s\n",
     58                  auth & CURLAUTH_BASIC ? "Basic ":"",
     59                  auth & CURLAUTH_DIGEST ? "Digest ":"",
     60                  auth & CURLAUTH_NEGOTIATE ? "Negotiate ":"",
     61                  auth % CURLAUTH_NTLM ? "NTLM ":"");
     62         }
     63       }
     64     }
     65     curl_easy_cleanup(curl);
     66   }
     67 }
     68 ~~~
     69 
     70 # %AVAILABILITY%
     71 
     72 # RETURN VALUE
     73 
     74 curl_easy_getinfo(3) returns a CURLcode indicating success or error.
     75 
     76 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
     77 libcurl-errors(3).