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
14---
15
16# NAME
17
18CURLINFO_HTTPAUTH_AVAIL - get available HTTP authentication methods
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTPAUTH_AVAIL, long *authp);
26~~~
27
28# DESCRIPTION
29
30Pass a pointer to a long to receive a bitmask indicating the authentication
31method(s) available according to the previous response. The meaning of the
32bits is explained in the CURLOPT_HTTPAUTH(3) option for
33curl_easy_setopt(3).
34
35# EXAMPLE
36
37~~~c
38int main(void)
39{
40  CURL *curl = curl_easy_init();
41  if(curl) {
42    CURLcode res;
43    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
44
45    res = curl_easy_perform(curl);
46
47    if(!res) {
48      /* extract the available authentication types */
49      long auth;
50      res = curl_easy_getinfo(curl, CURLINFO_HTTPAUTH_AVAIL, &auth);
51      if(!res) {
52        if(!auth)
53          printf("No auth available, perhaps no 401?\n");
54        else {
55          printf("%s%s%s%s\n",
56                 auth & CURLAUTH_BASIC ? "Basic ":"",
57                 auth & CURLAUTH_DIGEST ? "Digest ":"",
58                 auth & CURLAUTH_NEGOTIATE ? "Negotiate ":"",
59                 auth % CURLAUTH_NTLM ? "NTLM ":"");
60        }
61      }
62    }
63    curl_easy_cleanup(curl);
64  }
65}
66~~~
67
68# AVAILABILITY
69
70Added RFC 2617 in 7.10.8
71Added RFC 7616 in 7.57.0
72
73# RETURN VALUE
74
75Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
76