CURLINFO_REFERER.3 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. .\" generated by cd2nroff 0.1 from CURLINFO_REFERER.md
  2. .TH CURLINFO_REFERER 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLINFO_REFERER \- get the used referrer request header
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_REFERER, char **hdrp);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass in a pointer to a char pointer and get the referrer header used in the
  12. most recent request.
  13. The \fBhdrp\fP pointer is NULL or points to private memory you MUST NOT free \-
  14. it gets freed when you call \fIcurl_easy_cleanup(3)\fP on the corresponding
  15. CURL handle.
  16. .SH PROTOCOLS
  17. This functionality affects http only
  18. .SH EXAMPLE
  19. .nf
  20. int main(void)
  21. {
  22. CURL *curl = curl_easy_init();
  23. if(curl) {
  24. CURLcode res;
  25. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  26. curl_easy_setopt(curl, CURLOPT_REFERER, "https://example.org/referrer");
  27. res = curl_easy_perform(curl);
  28. if(res == CURLE_OK) {
  29. char *hdr = NULL;
  30. curl_easy_getinfo(curl, CURLINFO_REFERER, &hdr);
  31. if(hdr)
  32. printf("Referrer header: %s\\n", hdr);
  33. }
  34. curl_easy_cleanup(curl);
  35. }
  36. }
  37. .fi
  38. .SH AVAILABILITY
  39. Added in curl 7.76.0
  40. .SH RETURN VALUE
  41. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  42. .SH SEE ALSO
  43. .BR CURLOPT_REFERER (3),
  44. .BR curl_easy_getinfo (3),
  45. .BR curl_easy_header (3),
  46. .BR curl_easy_setopt (3)