1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLINFO_REFERER 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_REFERER (3) 9 - curl_easy_getinfo (3) 10 - curl_easy_header (3) 11 - curl_easy_setopt (3) 12--- 13 14# NAME 15 16CURLINFO_REFERER - get the used referrer request header 17 18# SYNOPSIS 19 20~~~c 21#include <curl/curl.h> 22 23CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_REFERER, char **hdrp); 24~~~ 25 26# DESCRIPTION 27 28Pass in a pointer to a char pointer and get the referrer header used in the 29most recent request. 30 31The **hdrp** pointer is NULL or points to private memory you MUST NOT free - 32it gets freed when you call curl_easy_cleanup(3) on the corresponding 33CURL handle. 34 35# PROTOCOLS 36 37HTTP(S) 38 39# EXAMPLE 40 41~~~c 42int main(void) 43{ 44 CURL *curl = curl_easy_init(); 45 if(curl) { 46 CURLcode res; 47 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 48 curl_easy_setopt(curl, CURLOPT_REFERER, "https://example.org/referrer"); 49 res = curl_easy_perform(curl); 50 if(res == CURLE_OK) { 51 char *hdr = NULL; 52 curl_easy_getinfo(curl, CURLINFO_REFERER, &hdr); 53 if(hdr) 54 printf("Referrer header: %s\n", hdr); 55 } 56 curl_easy_cleanup(curl); 57 } 58} 59~~~ 60 61# AVAILABILITY 62 63Added in 7.76.0 64 65# RETURN VALUE 66 67Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 68