CURLOPT_REFERER(3)
π CURLOPT_REFERER β the HTTP referer header
okay so bestie, welcome to CURLOPT_REFERER from the Library Functions Manual. yes this is literally the libcurl page for the referer header and no I will not be calm about it π
β¨ SYNOPSIS β¨
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REFERER, char *where);
that's it. that's the whole vibe check. π¦
πΈ DESCRIPTION πΈ
so you pass a pointer to a null-terminated string as the parameter, right? and that string is what gets used to set the Referer: header field in the HTTP request you send to the remote server. it's giving "hey bestie, I came from over there" energy π
and like β you can set any custom header with CURLOPT_HTTPHEADER(3) if you're feeling extra. no gatekeeping here π
the application does not have to keep the string around after setting this option. so go ahead, let it go, free yourself, it's fine πβ¨
Using this option multiple times makes the last set string override the previous ones. last one wins, no cap, the earlier ones are simply not the main character anymore π and if you set it to NULL you disable its use again. bye bye referer π«Ά
π DEFAULT π
NULL
(default is nothing, we start with nothing, it's a whole blank slate moment π )
π PROTOCOLS π
this functionality affects http only. literally just http. that's the whole list. periodt. π
β EXAMPLE β
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* tell it where we found the link to this place */
curl_easy_setopt(curl, CURLOPT_REFERER, "https://example.org/me.html");
curl_easy_perform(curl);
}
}
look at that comment β /* tell it where we found the link to this place */ β iconic, self-explanatory, 10/10, no notes π§
π¦ AVAILABILITY π¦
Added in curl 7.1. ancient. vintage. a classic. she's been here since forever and she ate π₯
π RETURN VALUE π
curl_easy_setopt(3) returns a CURLcode indicating success or error. that's the whole thing, she tells you how it went π«Ά
CURLE_OK(0) means everything was OK β¨ slay- non-zero means an error occurred π see
libcurl-errors(3)for the tea
π SEE ALSO π
go read them, they're all besties, iykyk π
ngl this page is short and sweet and that's her main character energy. no warnings, no bugs, no drama. just referer. π
kisses, this was libcurl, dated 2026-10-12 β mwah, see you in the next manpage bestie πΈππ
π¦ 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