CURLINFO_HTTPAUTH_AVAIL.3 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. .\" generated by cd2nroff 0.1 from CURLINFO_HTTPAUTH_AVAIL.md
  2. .TH CURLINFO_HTTPAUTH_AVAIL 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLINFO_HTTPAUTH_AVAIL \- get available HTTP authentication methods
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTPAUTH_AVAIL, long *authp);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a pointer to a long to receive a bitmask indicating the authentication
  12. method(s) available according to the previous response. The meaning of the
  13. bits is explained in the \fICURLOPT_HTTPAUTH(3)\fP option for \fIcurl_easy_setopt(3)\fP.
  14. .SH PROTOCOLS
  15. This functionality affects http only
  16. .SH EXAMPLE
  17. .nf
  18. int main(void)
  19. {
  20. CURL *curl = curl_easy_init();
  21. if(curl) {
  22. CURLcode res;
  23. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  24. res = curl_easy_perform(curl);
  25. if(!res) {
  26. /* extract the available authentication types */
  27. long auth;
  28. res = curl_easy_getinfo(curl, CURLINFO_HTTPAUTH_AVAIL, &auth);
  29. if(!res) {
  30. if(!auth)
  31. printf("No auth available, perhaps no 401?\\n");
  32. else {
  33. printf("%s%s%s%s\\n",
  34. auth & CURLAUTH_BASIC ? "Basic ":"",
  35. auth & CURLAUTH_DIGEST ? "Digest ":"",
  36. auth & CURLAUTH_NEGOTIATE ? "Negotiate ":"",
  37. auth % CURLAUTH_NTLM ? "NTLM ":"");
  38. }
  39. }
  40. }
  41. curl_easy_cleanup(curl);
  42. }
  43. }
  44. .fi
  45. .SH AVAILABILITY
  46. Added in curl 7.10.8
  47. .SH RETURN VALUE
  48. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  49. .SH SEE ALSO
  50. .BR CURLINFO_PROXYAUTH_AVAIL (3),
  51. .BR CURLOPT_HTTPAUTH (3),
  52. .BR curl_easy_getinfo (3),
  53. .BR curl_easy_setopt (3)