CURLINFO_USED_PROXY: return bool whether the proxy was used

Adds test536 to verify

Closes #12719
This commit is contained in:
Daniel Stenberg 2024-02-22 08:38:53 +01:00
parent d5b0fee39a
commit cc04c73677
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
12 changed files with 259 additions and 4 deletions

View file

@ -120,6 +120,10 @@ See CURLINFO_PRETRANSFER_TIME_T(3)
Time during which this transfer was held in a waiting queue.
See CURLINFO_QUEUE_TIME_T(3)
## CURLINFO_USED_PROXY
Whether the proxy was used (Added in 8.7.0). See CURLINFO_USED_PROXY(3)
## CURLINFO_STARTTRANSFER_TIME
Time from start until just when the first byte is received.

View file

@ -0,0 +1,69 @@
---
c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_USED_PROXY
Section: 3
Source: libcurl
See-also:
- CURLOPT_NOPROXY (3)
- CURLOPT_PROXY (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
---
# NAME
CURLINFO_USED_PROXY - whether the transfer used a proxy
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_USED_PROXY,
long *authp);
~~~
# DESCRIPTION
Pass a pointer to a long. It gets set to zero set if no proxy was used in the
previous transfer or a non-zero value if a proxy was used.
# PROTOCOLS
HTTP(S)
# EXAMPLE
~~~c
int main(int argc, char *argv[])
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1:80");
curl_easy_setopt(curl, CURLOPT_NOPROXY, "example.com");
res = curl_easy_perform(curl);
if(!res) {
/* extract the available proxy authentication types */
long used;
res = curl_easy_getinfo(curl, CURLINFO_USED_PROXY, &used);
if(!res) {
printf("The proxy was %sused\n", used ? "": "NOT ");
}
}
curl_easy_cleanup(curl);
}
}
~~~
# AVAILABILITY
Added in 8.7.0
# RETURN VALUE
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.

View file

@ -95,6 +95,7 @@ man_MANS = \
CURLINFO_TLS_SSL_PTR.3 \
CURLINFO_TOTAL_TIME.3 \
CURLINFO_TOTAL_TIME_T.3 \
CURLINFO_USED_PROXY.3 \
CURLINFO_XFER_ID.3 \
CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE.3 \
CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE.3 \

View file

@ -506,6 +506,7 @@ CURLINFO_TLS_SSL_PTR 7.48.0
CURLINFO_TOTAL_TIME 7.4.1
CURLINFO_TOTAL_TIME_T 7.61.0
CURLINFO_TYPEMASK 7.4.1
CURLINFO_USED_PROXY 8.7.0
CURLINFO_XFER_ID 8.2.0
CURLIOCMD_NOP 7.12.3
CURLIOCMD_RESTARTREAD 7.12.3