1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLINFO_USED_PROXY
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_NOPROXY (3)
9  - CURLOPT_PROXY (3)
10  - curl_easy_getinfo (3)
11  - curl_easy_setopt (3)
12Protocol:
13  - All
14Added-in: 8.7.0
15---
16
17# NAME
18
19CURLINFO_USED_PROXY - whether the transfer used a proxy
20
21# SYNOPSIS
22
23~~~c
24#include <curl/curl.h>
25
26CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_USED_PROXY,
27                           long *authp);
28~~~
29
30# DESCRIPTION
31
32Pass a pointer to a long. It gets set to zero set if no proxy was used in the
33previous transfer or a non-zero value if a proxy was used.
34
35# %PROTOCOLS%
36
37# EXAMPLE
38
39~~~c
40int 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
68Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
69