xref: /aosp_15_r20/external/curl/docs/libcurl/opts/CURLOPT_PROXYHEADER.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_PROXYHEADER
5*6236dae4SAndroid Build Coastguard WorkerSection: 3
6*6236dae4SAndroid Build Coastguard WorkerSource: libcurl
7*6236dae4SAndroid Build Coastguard WorkerSee-also:
8*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_HEADEROPT (3)
9*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_HTTPHEADER (3)
10*6236dae4SAndroid Build Coastguard WorkerProtocol:
11*6236dae4SAndroid Build Coastguard Worker  - All
12*6236dae4SAndroid Build Coastguard WorkerAdded-in: 7.37.0
13*6236dae4SAndroid Build Coastguard Worker---
14*6236dae4SAndroid Build Coastguard Worker
15*6236dae4SAndroid Build Coastguard Worker# NAME
16*6236dae4SAndroid Build Coastguard Worker
17*6236dae4SAndroid Build Coastguard WorkerCURLOPT_PROXYHEADER - set of HTTP headers to pass to proxy
18*6236dae4SAndroid Build Coastguard Worker
19*6236dae4SAndroid Build Coastguard Worker# SYNOPSIS
20*6236dae4SAndroid Build Coastguard Worker
21*6236dae4SAndroid Build Coastguard Worker~~~c
22*6236dae4SAndroid Build Coastguard Worker#include <curl/curl.h>
23*6236dae4SAndroid Build Coastguard Worker
24*6236dae4SAndroid Build Coastguard WorkerCURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYHEADER,
25*6236dae4SAndroid Build Coastguard Worker                          struct curl_slist *headers);
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 linked list of HTTP headers to pass in your HTTP request
31*6236dae4SAndroid Build Coastguard Workersent to a proxy. The rules for this list is identical to the
32*6236dae4SAndroid Build Coastguard WorkerCURLOPT_HTTPHEADER(3) option's.
33*6236dae4SAndroid Build Coastguard Worker
34*6236dae4SAndroid Build Coastguard WorkerThe headers set with this option is only ever used in requests sent to a proxy
35*6236dae4SAndroid Build Coastguard Worker- when there is also a request sent to a host.
36*6236dae4SAndroid Build Coastguard Worker
37*6236dae4SAndroid Build Coastguard WorkerThe first line in a request (containing the method, usually a GET or POST) is
38*6236dae4SAndroid Build Coastguard WorkerNOT a header and cannot be replaced using this option. Only the lines
39*6236dae4SAndroid Build Coastguard Workerfollowing the request-line are headers. Adding this method line in this list
40*6236dae4SAndroid Build Coastguard Workerof headers causes your request to send an invalid header.
41*6236dae4SAndroid Build Coastguard Worker
42*6236dae4SAndroid Build Coastguard WorkerUsing this option multiple times makes the last set list override the previous
43*6236dae4SAndroid Build Coastguard Workerones. Set it to NULL to disable its use again.
44*6236dae4SAndroid Build Coastguard Worker
45*6236dae4SAndroid Build Coastguard Workerlibcurl does not copy the list, it needs to be kept around until after the
46*6236dae4SAndroid Build Coastguard Workertransfer has completed.
47*6236dae4SAndroid Build Coastguard Worker
48*6236dae4SAndroid Build Coastguard Worker# DEFAULT
49*6236dae4SAndroid Build Coastguard Worker
50*6236dae4SAndroid Build Coastguard WorkerNULL
51*6236dae4SAndroid Build Coastguard Worker
52*6236dae4SAndroid Build Coastguard Worker# %PROTOCOLS%
53*6236dae4SAndroid Build Coastguard Worker
54*6236dae4SAndroid Build Coastguard Worker# EXAMPLE
55*6236dae4SAndroid Build Coastguard Worker
56*6236dae4SAndroid Build Coastguard Worker~~~c
57*6236dae4SAndroid Build Coastguard Workerint main(void)
58*6236dae4SAndroid Build Coastguard Worker{
59*6236dae4SAndroid Build Coastguard Worker  CURL *curl = curl_easy_init();
60*6236dae4SAndroid Build Coastguard Worker
61*6236dae4SAndroid Build Coastguard Worker  struct curl_slist *list;
62*6236dae4SAndroid Build Coastguard Worker
63*6236dae4SAndroid Build Coastguard Worker  if(curl) {
64*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
65*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy.example.com:80");
66*6236dae4SAndroid Build Coastguard Worker
67*6236dae4SAndroid Build Coastguard Worker    list = curl_slist_append(NULL, "Shoesize: 10");
68*6236dae4SAndroid Build Coastguard Worker    list = curl_slist_append(list, "Accept:");
69*6236dae4SAndroid Build Coastguard Worker
70*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_PROXYHEADER, list);
71*6236dae4SAndroid Build Coastguard Worker
72*6236dae4SAndroid Build Coastguard Worker    curl_easy_perform(curl);
73*6236dae4SAndroid Build Coastguard Worker
74*6236dae4SAndroid Build Coastguard Worker    curl_slist_free_all(list); /* free the list again */
75*6236dae4SAndroid Build Coastguard Worker  }
76*6236dae4SAndroid Build Coastguard Worker}
77*6236dae4SAndroid Build Coastguard Worker~~~
78*6236dae4SAndroid Build Coastguard Worker
79*6236dae4SAndroid Build Coastguard Worker# %AVAILABILITY%
80*6236dae4SAndroid Build Coastguard Worker
81*6236dae4SAndroid Build Coastguard Worker# RETURN VALUE
82*6236dae4SAndroid Build Coastguard Worker
83*6236dae4SAndroid Build Coastguard WorkerReturns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
84