1--- 2c: Copyright (C) Daniel Stenberg, <daniel.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) 12--- 13 14# NAME 15 16CURLINFO_HTTPAUTH_AVAIL - get available HTTP authentication methods 17 18# SYNOPSIS 19 20~~~c 21#include <curl/curl.h> 22 23CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTPAUTH_AVAIL, long *authp); 24~~~ 25 26# DESCRIPTION 27 28Pass a pointer to a long to receive a bitmask indicating the authentication 29method(s) available according to the previous response. The meaning of the 30bits is explained in the CURLOPT_HTTPAUTH(3) option for 31curl_easy_setopt(3). 32 33# PROTOCOLS 34 35HTTP(S) 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 72Added RFC 2617 in 7.10.8 73Added RFC 7616 in 7.57.0 74 75# RETURN VALUE 76 77Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 78