1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_REFERER 5Section: 3 6Source: libcurl 7See-also: 8 - CURLINFO_REDIRECT_URL (3) 9 - CURLINFO_REFERER (3) 10 - CURLOPT_HTTPHEADER (3) 11 - CURLOPT_USERAGENT (3) 12--- 13 14# NAME 15 16CURLOPT_REFERER - the HTTP referer header 17 18# SYNOPSIS 19 20~~~c 21#include <curl/curl.h> 22 23CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REFERER, char *where); 24~~~ 25 26# DESCRIPTION 27 28Pass a pointer to a null-terminated string as parameter. It is used to set the 29Referer: header field in the HTTP request sent to the remote server. You can 30set any custom header with CURLOPT_HTTPHEADER(3). 31 32The application does not have to keep the string around after setting this 33option. 34 35# DEFAULT 36 37NULL 38 39# PROTOCOLS 40 41HTTP 42 43# EXAMPLE 44 45~~~c 46int main(void) 47{ 48 CURL *curl = curl_easy_init(); 49 if(curl) { 50 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 51 52 /* tell it where we found the link to this place */ 53 curl_easy_setopt(curl, CURLOPT_REFERER, "https://example.org/me.html"); 54 55 curl_easy_perform(curl); 56 } 57} 58~~~ 59 60# AVAILABILITY 61 62If built with HTTP support 63 64# RETURN VALUE 65 66Returns CURLE_OK if HTTP support is enabled, CURLE_UNKNOWN_OPTION if not, or 67CURLE_OUT_OF_MEMORY if there was insufficient heap space. 68