CURLOPT_REFERER.md (1449B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_REFERER 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLINFO_REDIRECT_URL (3) 9 - CURLINFO_REFERER (3) 10 - CURLOPT_HTTPHEADER (3) 11 - CURLOPT_USERAGENT (3) 12 Protocol: 13 - HTTP 14 Added-in: 7.1 15 --- 16 17 # NAME 18 19 CURLOPT_REFERER - the HTTP referer header 20 21 # SYNOPSIS 22 23 ~~~c 24 #include <curl/curl.h> 25 26 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REFERER, char *where); 27 ~~~ 28 29 # DESCRIPTION 30 31 Pass a pointer to a null-terminated string as parameter. It is used to set the 32 Referer: header field in the HTTP request sent to the remote server. You can 33 set any custom header with CURLOPT_HTTPHEADER(3). 34 35 The application does not have to keep the string around after setting this 36 option. 37 38 Using this option multiple times makes the last set string override the 39 previous ones. Set it to NULL to disable its use again. 40 41 # DEFAULT 42 43 NULL 44 45 # %PROTOCOLS% 46 47 # EXAMPLE 48 49 ~~~c 50 int main(void) 51 { 52 CURL *curl = curl_easy_init(); 53 if(curl) { 54 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 55 56 /* tell it where we found the link to this place */ 57 curl_easy_setopt(curl, CURLOPT_REFERER, "https://example.org/me.html"); 58 59 curl_easy_perform(curl); 60 } 61 } 62 ~~~ 63 64 # %AVAILABILITY% 65 66 # RETURN VALUE 67 68 curl_easy_setopt(3) returns a CURLcode indicating success or error. 69 70 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 71 libcurl-errors(3).