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