CURLINFO_USED_PROXY.md (1492B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLINFO_USED_PROXY 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_NOPROXY (3) 9 - CURLOPT_PROXY (3) 10 - curl_easy_getinfo (3) 11 - curl_easy_setopt (3) 12 Protocol: 13 - All 14 Added-in: 8.7.0 15 --- 16 17 # NAME 18 19 CURLINFO_USED_PROXY - whether the transfer used a proxy 20 21 # SYNOPSIS 22 23 ~~~c 24 #include <curl/curl.h> 25 26 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_USED_PROXY, 27 long *authp); 28 ~~~ 29 30 # DESCRIPTION 31 32 Pass a pointer to a long. It gets set to zero set if no proxy was used in the 33 previous transfer or a non-zero value if a proxy was used. 34 35 # %PROTOCOLS% 36 37 # EXAMPLE 38 39 ~~~c 40 int main(int argc, char *argv[]) 41 { 42 CURL *curl = curl_easy_init(); 43 if(curl) { 44 CURLcode res; 45 curl_easy_setopt(curl, CURLOPT_URL, argv[1]); 46 curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1:80"); 47 curl_easy_setopt(curl, CURLOPT_NOPROXY, "example.com"); 48 49 res = curl_easy_perform(curl); 50 51 if(!res) { 52 /* extract the available proxy authentication types */ 53 long used; 54 res = curl_easy_getinfo(curl, CURLINFO_USED_PROXY, &used); 55 if(!res) { 56 printf("The proxy was %sused\n", used ? "": "NOT "); 57 } 58 } 59 curl_easy_cleanup(curl); 60 } 61 } 62 ~~~ 63 64 # %AVAILABILITY% 65 66 # RETURN VALUE 67 68 curl_easy_getinfo(3) returns a CURLcode indicating success or error. 69 70 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 71 libcurl-errors(3).