xref: /curl/docs/libcurl/opts/CURLOPT_REFERER.md (revision e3fe0200)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_REFERER
5Section: 3
6Source: libcurl
7See-also:
8  - CURLINFO_REDIRECT_URL (3)
9  - CURLINFO_REFERER (3)
10  - CURLOPT_HTTPHEADER (3)
11  - CURLOPT_USERAGENT (3)
12Protocol:
13  - HTTP
14---
15
16# NAME
17
18CURLOPT_REFERER - the HTTP referer header
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REFERER, char *where);
26~~~
27
28# DESCRIPTION
29
30Pass a pointer to a null-terminated string as parameter. It is used to set the
31Referer: header field in the HTTP request sent to the remote server. You can
32set any custom header with CURLOPT_HTTPHEADER(3).
33
34The application does not have to keep the string around after setting this
35option.
36
37# DEFAULT
38
39NULL
40
41# EXAMPLE
42
43~~~c
44int main(void)
45{
46  CURL *curl = curl_easy_init();
47  if(curl) {
48    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
49
50    /* tell it where we found the link to this place */
51    curl_easy_setopt(curl, CURLOPT_REFERER, "https://example.org/me.html");
52
53    curl_easy_perform(curl);
54  }
55}
56~~~
57
58# AVAILABILITY
59
60If built with HTTP support
61
62# RETURN VALUE
63
64Returns CURLE_OK if HTTP support is enabled, CURLE_UNKNOWN_OPTION if not, or
65CURLE_OUT_OF_MEMORY if there was insufficient heap space.
66