CURLINFO_EFFECTIVE_URL.3 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. .\" generated by cd2nroff 0.1 from CURLINFO_EFFECTIVE_URL.md
  2. .TH CURLINFO_EFFECTIVE_URL 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLINFO_EFFECTIVE_URL \- get the last used URL
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_EFFECTIVE_URL, char **urlp);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass in a pointer to a char pointer and get the last used effective URL.
  12. In cases when you have asked libcurl to follow redirects, it may not be the same
  13. value you set with \fICURLOPT_URL(3)\fP.
  14. The \fBurlp\fP pointer is NULL or points to private memory. You MUST NOT free
  15. - it gets freed when you call \fIcurl_easy_cleanup(3)\fP on the corresponding
  16. CURL handle.
  17. .SH PROTOCOLS
  18. This functionality affects http only
  19. .SH EXAMPLE
  20. .nf
  21. int main(void)
  22. {
  23. CURL *curl = curl_easy_init();
  24. if(curl) {
  25. CURLcode res;
  26. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  27. curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  28. res = curl_easy_perform(curl);
  29. if(res == CURLE_OK) {
  30. char *url = NULL;
  31. curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
  32. if(url)
  33. printf("Redirect to: %s\\n", url);
  34. }
  35. curl_easy_cleanup(curl);
  36. }
  37. }
  38. .fi
  39. .SH AVAILABILITY
  40. Added in curl 7.4
  41. .SH RETURN VALUE
  42. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  43. .SH SEE ALSO
  44. .BR CURLOPT_FOLLOWLOCATION (3),
  45. .BR curl_easy_getinfo (3),
  46. .BR curl_easy_setopt (3)