xref: /curl/docs/libcurl/opts/CURLOPT_REFERER.md (revision c4ab3337)
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
14Added-in: 7.1
15---
16
17# NAME
18
19CURLOPT_REFERER - the HTTP referer header
20
21# SYNOPSIS
22
23~~~c
24#include <curl/curl.h>
25
26CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REFERER, char *where);
27~~~
28
29# DESCRIPTION
30
31Pass a pointer to a null-terminated string as parameter. It is used to set the
32Referer: header field in the HTTP request sent to the remote server. You can
33set any custom header with CURLOPT_HTTPHEADER(3).
34
35The application does not have to keep the string around after setting this
36option.
37
38Using this option multiple times makes the last set string override the
39previous ones. Set it to NULL to disable its use again.
40
41# DEFAULT
42
43NULL
44
45# %PROTOCOLS%
46
47# EXAMPLE
48
49~~~c
50int main(void)
51{
52  CURL *curl = curl_easy_init();
53  if(curl) {
54    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
55
56    /* tell it where we found the link to this place */
57    curl_easy_setopt(curl, CURLOPT_REFERER, "https://example.org/me.html");
58
59    curl_easy_perform(curl);
60  }
61}
62~~~
63
64# %AVAILABILITY%
65
66# RETURN VALUE
67
68Returns CURLE_OK if HTTP support is enabled, CURLE_UNKNOWN_OPTION if not, or
69CURLE_OUT_OF_MEMORY if there was insufficient heap space.
70