CURLOPT_AUTOREFERER.3 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. .\" generated by cd2nroff 0.1 from CURLOPT_AUTOREFERER.md
  2. .TH CURLOPT_AUTOREFERER 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_AUTOREFERER \- automatically update the referer header
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_AUTOREFERER, long autorefer);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long parameter set to 1 to enable this. When enabled, libcurl
  12. automatically sets the Referer: header field in HTTP requests to the full URL
  13. when it follows a Location: redirect to a new destination.
  14. The automatic referer is set to the full previous URL even when redirects are
  15. done cross\-origin or following redirects to insecure protocols. This is
  16. considered a minor privacy leak by some.
  17. With \fICURLINFO_REFERER(3)\fP, applications can extract the actually used
  18. referer header after the transfer.
  19. .SH DEFAULT
  20. 0, disabled
  21. .SH PROTOCOLS
  22. This functionality affects http only
  23. .SH EXAMPLE
  24. .nf
  25. int main(void)
  26. {
  27. CURL *curl = curl_easy_init();
  28. if(curl) {
  29. CURLcode res;
  30. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
  31. /* follow redirects */
  32. curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  33. /* set Referer: automatically when following redirects */
  34. curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1L);
  35. res = curl_easy_perform(curl);
  36. curl_easy_cleanup(curl);
  37. }
  38. }
  39. .fi
  40. .SH AVAILABILITY
  41. Added in curl 7.1
  42. .SH RETURN VALUE
  43. Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
  44. .SH SEE ALSO
  45. .BR CURLINFO_EFFECTIVE_URL (3),
  46. .BR CURLINFO_REDIRECT_URL (3),
  47. .BR CURLINFO_REFERER (3),
  48. .BR CURLOPT_FOLLOWLOCATION (3),
  49. .BR CURLOPT_REFERER (3)