CURLINFO_PROXYAUTH_USED.md (1930B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLINFO_PROXYAUTH_USED 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLINFO_HTTPAUTH_USED (3) 9 - CURLINFO_PROXYAUTH_AVAIL (3) 10 - CURLOPT_HTTPAUTH (3) 11 Protocol: 12 - HTTP 13 Added-in: 8.12.0 14 --- 15 16 # NAME 17 18 CURLINFO_PROXYAUTH_USED - get used HTTP proxy authentication method 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PROXYAUTH_USED, long *authp); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass a pointer to a long to receive a bitmask indicating the authentication 31 method that was used in the previous request done over an HTTP proxy. The 32 meaning of the possible bits is explained in the CURLOPT_HTTPAUTH(3) option 33 for curl_easy_setopt(3). 34 35 The returned value has zero or one bit set. 36 37 # %PROTOCOLS% 38 39 # EXAMPLE 40 41 ~~~c 42 int main(void) 43 { 44 CURL *curl = curl_easy_init(); 45 if(curl) { 46 CURLcode res; 47 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 48 curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy.example.com"); 49 curl_easy_setopt(curl, CURLOPT_PROXYAUTH, 50 CURLAUTH_BASIC | CURLAUTH_DIGEST); 51 curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME, "shrek"); 52 curl_easy_setopt(curl, CURLOPT_PROXYPASSWORD, "swamp"); 53 54 res = curl_easy_perform(curl); 55 56 if(!res) { 57 long auth; 58 res = curl_easy_getinfo(curl, CURLINFO_PROXYAUTH_USED, &auth); 59 if(!res) { 60 if(!auth) 61 printf("No auth used\n"); 62 else { 63 if(auth == CURLAUTH_DIGEST) 64 printf("Used Digest proxy authentication\n"); 65 else 66 printf("Used Basic proxy authentication\n"); 67 } 68 } 69 } 70 curl_easy_cleanup(curl); 71 } 72 } 73 ~~~ 74 75 # %AVAILABILITY% 76 77 # RETURN VALUE 78 79 curl_easy_getinfo(3) returns a CURLcode indicating success or error. 80 81 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 82 libcurl-errors(3).