1CURLOPT_AUTOREFERER(3) libcurl CURLOPT_AUTOREFERER(3)
2
3
4
6 CURLOPT_AUTOREFERER - automatically update the referer header
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_AUTOREFERER, long autorefer);
12
14 Pass a long parameter set to 1 to enable this. When enabled, libcurl
15 will automatically set the Referer: header field in HTTP requests to
16 the full URL where it follows a Location: redirect.
17
18 The automatic referer is set to the full previous URL even when redi‐
19 rects are done cross-origin or following redirects to insecure proto‐
20 cols. This is considered a minor privacy leak by some.
21
23 0, disabled
24
26 HTTP
27
29 CURL *curl = curl_easy_init();
30 if(curl) {
31 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
32
33 /* follow redirects */
34 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
35
36 /* set Referer: automatically when following redirects */
37 curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1L);
38
39 ret = curl_easy_perform(curl);
40
41 curl_easy_cleanup(curl);
42 }
43
45 Along with HTTP
46
48 Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
49
51 CURLOPT_REFERER(3), CURLOPT_FOLLOWLOCATION(3),
52
53
54
55ibcurl 8.2.1 April 26, 2023 CURLOPT_AUTOREFERER(3)