1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_AUTOREFERER 5Section: 3 6Source: libcurl 7See-also: 8 - CURLINFO_EFFECTIVE_URL (3) 9 - CURLINFO_REDIRECT_URL (3) 10 - CURLINFO_REFERER (3) 11 - CURLOPT_FOLLOWLOCATION (3) 12 - CURLOPT_REFERER (3) 13--- 14 15# NAME 16 17CURLOPT_AUTOREFERER - automatically update the referer header 18 19# SYNOPSIS 20 21~~~c 22#include <curl/curl.h> 23 24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_AUTOREFERER, long autorefer); 25~~~ 26 27# DESCRIPTION 28 29Pass a long parameter set to 1 to enable this. When enabled, libcurl 30automatically sets the Referer: header field in HTTP requests to the full URL 31when it follows a Location: redirect to a new destination. 32 33The automatic referer is set to the full previous URL even when redirects are 34done cross-origin or following redirects to insecure protocols. This is 35considered a minor privacy leak by some. 36 37With CURLINFO_REFERER(3), applications can extract the actually used 38referer header after the transfer. 39 40# DEFAULT 41 420, disabled 43 44# PROTOCOLS 45 46HTTP 47 48# EXAMPLE 49 50~~~c 51int main(void) 52{ 53 CURL *curl = curl_easy_init(); 54 if(curl) { 55 CURLcode res; 56 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); 57 58 /* follow redirects */ 59 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); 60 61 /* set Referer: automatically when following redirects */ 62 curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1L); 63 64 res = curl_easy_perform(curl); 65 66 curl_easy_cleanup(curl); 67 } 68} 69~~~ 70 71# AVAILABILITY 72 73Along with HTTP 74 75# RETURN VALUE 76 77Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. 78