1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLINFO_HTTPAUTH_AVAIL 5Section: 3 6Source: libcurl 7See-also: 8 - CURLINFO_PROXYAUTH_AVAIL (3) 9 - CURLOPT_HTTPAUTH (3) 10 - curl_easy_getinfo (3) 11 - curl_easy_setopt (3) 12Protocol: 13 - HTTP 14Added-in: 7.10.8 15--- 16 17# NAME 18 19CURLINFO_HTTPAUTH_AVAIL - get available HTTP authentication methods 20 21# SYNOPSIS 22 23~~~c 24#include <curl/curl.h> 25 26CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTPAUTH_AVAIL, long *authp); 27~~~ 28 29# DESCRIPTION 30 31Pass a pointer to a long to receive a bitmask indicating the authentication 32method(s) available according to the previous response. The meaning of the 33bits is explained in the CURLOPT_HTTPAUTH(3) option for curl_easy_setopt(3). 34 35# %PROTOCOLS% 36 37# EXAMPLE 38 39~~~c 40int 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 74Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 75