CURLINFO_REFERER(3)
π CURLINFO_REFERER β bestie, let's peek at your HTTP referrer β¨
okay so this is CURLINFO_REFERER, a libcurl thing, straight out of the Library Functions Manual. it's the little incantation you use to find out what referrer header got sent, no cap π
β¨ NAME β¨
CURLINFO_REFERER β the option that grabs the used HTTP referrer request header. that's it, that's the whole vibe π
π¦ SYNOPSIS π¦
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_REFERER, char **hdrp);
like, look at her. three args, zero drama π«Ά
πΈ DESCRIPTION πΈ
so here's the tea: you pass in a pointer to a char pointer, and the function hands you back the referrer header used in the most recent request. that's literally it. main character info retrieval π
now the important part, bestie, do not skip this:
- the
hdrppointer is eitherNULLor it points to private memory - you must not free it β nope, not yours, hands off π
- that memory gets freed automatically when you call
curl_easy_cleanup(3)on the corresponding curl handle. it's giving built-in cleanup, iykyk β¨
π PROTOCOLS π
this functionality affects http only. that's the whole section. periodt. π§
π EXAMPLE π
here's the actual code, copied exactly because we don't play with literals π
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_REFERER, "https://example.org/referrer");
result = curl_easy_perform(curl);
if(result == CURLE_OK) {
char *hdr = NULL;
curl_easy_getinfo(curl, CURLINFO_REFERER, &hdr);
if(hdr)
printf("Referrer header: %s\n", hdr);
}
curl_easy_cleanup(curl);
}
}
so you init the handle, set CURLOPT_URL to "https://example.com", set CURLOPT_REFERER to "https://example.org/referrer", perform the request, and if it came back CURLE_OK you grab the header into hdr and print it with printf("Referrer header: %s\n", hdr). then curl_easy_cleanup because we're responsible besties π and yes the if(hdr) check is there, we stan a NULL check π
π¦ AVAILABILITY π¦
added in curl 7.76.0. if your curl is older than that, this vibe check fails, sorry π
π RETURN VALUE π
curl_easy_getinfo(3) returns a CURLcode that's either success or error, no in-between bestie:
CURLE_OK(0) β everything was OK, we ate π₯- non-zero β an error occurred, and you should go see
libcurl-errors(3)for the details
π SEE ALSO π
reminder bestie: do not free the memory you get back fromCURLINFO_REFERER.curl_easy_cleanup(3)handles that. free it yourself and you'll be in undefined-behaviour territory, which is not the slay you want π
okay that's the whole page, ily, go grab your referrer headers responsibly πβ¨
β written by the libcurl girlies, libcurl, dated 2026-10-12, and that's the CURLINFO_REFERER(3) page, periodt π«ΆπΈ
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms