xref: /aosp_15_r20/external/curl/docs/libcurl/opts/CURLOPT_NOPROXY.md (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker---
2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al.
3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl
4*6236dae4SAndroid Build Coastguard WorkerTitle: CURLOPT_NOPROXY
5*6236dae4SAndroid Build Coastguard WorkerSection: 3
6*6236dae4SAndroid Build Coastguard WorkerSource: libcurl
7*6236dae4SAndroid Build Coastguard WorkerProtocol:
8*6236dae4SAndroid Build Coastguard Worker  - All
9*6236dae4SAndroid Build Coastguard WorkerSee-also:
10*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_PROXY (3)
11*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_PROXYAUTH (3)
12*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_PROXYTYPE (3)
13*6236dae4SAndroid Build Coastguard WorkerAdded-in: 7.19.4
14*6236dae4SAndroid Build Coastguard Worker---
15*6236dae4SAndroid Build Coastguard Worker
16*6236dae4SAndroid Build Coastguard Worker# NAME
17*6236dae4SAndroid Build Coastguard Worker
18*6236dae4SAndroid Build Coastguard WorkerCURLOPT_NOPROXY - disable proxy use for specific hosts
19*6236dae4SAndroid Build Coastguard Worker
20*6236dae4SAndroid Build Coastguard Worker# SYNOPSIS
21*6236dae4SAndroid Build Coastguard Worker
22*6236dae4SAndroid Build Coastguard Worker~~~c
23*6236dae4SAndroid Build Coastguard Worker#include <curl/curl.h>
24*6236dae4SAndroid Build Coastguard Worker
25*6236dae4SAndroid Build Coastguard WorkerCURLcode curl_easy_setopt(CURL *handle, CURLOPT_NOPROXY, char *noproxy);
26*6236dae4SAndroid Build Coastguard Worker~~~
27*6236dae4SAndroid Build Coastguard Worker
28*6236dae4SAndroid Build Coastguard Worker# DESCRIPTION
29*6236dae4SAndroid Build Coastguard Worker
30*6236dae4SAndroid Build Coastguard WorkerPass a pointer to a null-terminated string. The string consists of a comma
31*6236dae4SAndroid Build Coastguard Workerseparated list of hostnames that do not require a proxy to get reached, even
32*6236dae4SAndroid Build Coastguard Workerif one is specified. The only wildcard available is a single * character,
33*6236dae4SAndroid Build Coastguard Workerwhich matches all hosts, and effectively disables the proxy. Each name in this
34*6236dae4SAndroid Build Coastguard Workerlist is matched as either a domain which contains the hostname, or the
35*6236dae4SAndroid Build Coastguard Workerhostname itself. For example, "ample.com" would match ample.com, ample.com:80,
36*6236dae4SAndroid Build Coastguard Workerand www.ample.com, but not www.example.com or ample.com.org.
37*6236dae4SAndroid Build Coastguard Worker
38*6236dae4SAndroid Build Coastguard WorkerSetting the *noproxy* string to "" (an empty string) explicitly enables the
39*6236dae4SAndroid Build Coastguard Workerproxy for all hostnames, even if there is an environment variable set for it.
40*6236dae4SAndroid Build Coastguard Worker
41*6236dae4SAndroid Build Coastguard WorkerEnter IPv6 numerical addresses in the list of hostnames without enclosing
42*6236dae4SAndroid Build Coastguard Workerbrackets:
43*6236dae4SAndroid Build Coastguard Worker
44*6236dae4SAndroid Build Coastguard Worker    "example.com,::1,localhost"
45*6236dae4SAndroid Build Coastguard Worker
46*6236dae4SAndroid Build Coastguard WorkerSince 7.86.0, IP addresses specified to this option can be provided using CIDR
47*6236dae4SAndroid Build Coastguard Workernotation: an appended slash and number specifies the number of "network bits"
48*6236dae4SAndroid Build Coastguard Workerout of the address to use in the comparison. For example "192.168.0.0/16"
49*6236dae4SAndroid Build Coastguard Workerwould match all addresses starting with "192.168".
50*6236dae4SAndroid Build Coastguard Worker
51*6236dae4SAndroid Build Coastguard WorkerThe application does not have to keep the string around after setting this
52*6236dae4SAndroid Build Coastguard Workeroption.
53*6236dae4SAndroid Build Coastguard Worker
54*6236dae4SAndroid Build Coastguard WorkerUsing this option multiple times makes the last set string override the
55*6236dae4SAndroid Build Coastguard Workerprevious ones. Set it to NULL to disable its use again.
56*6236dae4SAndroid Build Coastguard Worker
57*6236dae4SAndroid Build Coastguard Worker# Environment variables
58*6236dae4SAndroid Build Coastguard Worker
59*6236dae4SAndroid Build Coastguard WorkerIf there is an environment variable called **no_proxy** (or **NO_PROXY**),
60*6236dae4SAndroid Build Coastguard Workerit is used if the CURLOPT_NOPROXY(3) option is not set. It works exactly
61*6236dae4SAndroid Build Coastguard Workerthe same way.
62*6236dae4SAndroid Build Coastguard Worker
63*6236dae4SAndroid Build Coastguard Worker# DEFAULT
64*6236dae4SAndroid Build Coastguard Worker
65*6236dae4SAndroid Build Coastguard WorkerNULL
66*6236dae4SAndroid Build Coastguard Worker
67*6236dae4SAndroid Build Coastguard Worker# %PROTOCOLS%
68*6236dae4SAndroid Build Coastguard Worker
69*6236dae4SAndroid Build Coastguard Worker# EXAMPLE
70*6236dae4SAndroid Build Coastguard Worker
71*6236dae4SAndroid Build Coastguard Worker~~~c
72*6236dae4SAndroid Build Coastguard Workerint main(void)
73*6236dae4SAndroid Build Coastguard Worker{
74*6236dae4SAndroid Build Coastguard Worker  CURL *curl = curl_easy_init();
75*6236dae4SAndroid Build Coastguard Worker  if(curl) {
76*6236dae4SAndroid Build Coastguard Worker    /* accept various URLs */
77*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
78*6236dae4SAndroid Build Coastguard Worker    /* use this proxy */
79*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80");
80*6236dae4SAndroid Build Coastguard Worker    /* ... but make sure this host name is not proxied */
81*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_NOPROXY, "www.example.com");
82*6236dae4SAndroid Build Coastguard Worker    curl_easy_perform(curl);
83*6236dae4SAndroid Build Coastguard Worker  }
84*6236dae4SAndroid Build Coastguard Worker}
85*6236dae4SAndroid Build Coastguard Worker~~~
86*6236dae4SAndroid Build Coastguard Worker
87*6236dae4SAndroid Build Coastguard Worker# %AVAILABILITY%
88*6236dae4SAndroid Build Coastguard Worker
89*6236dae4SAndroid Build Coastguard Worker# RETURN VALUE
90*6236dae4SAndroid Build Coastguard Worker
91*6236dae4SAndroid Build Coastguard WorkerReturns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
92*6236dae4SAndroid Build Coastguard WorkerCURLE_OUT_OF_MEMORY if there was insufficient heap space.
93