1CURLINFO_EFFECTIVE_URL(3) curl_easy_getinfo options CURLINFO_EFFECTIVE_URL(3)
2
3
4
6 CURLINFO_EFFECTIVE_URL - get the last used URL
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_EFFECTIVE_URL, char **urlp);
12
14 Pass in a pointer to a char pointer and get the last used effective
15 URL.
16
17 In cases when you have asked libcurl to follow redirects, it may not be
18 the same value you set with CURLOPT_URL(3).
19
20 The urlp pointer will be NULL or pointing to private memory you MUST
21 NOT free - it gets freed when you call curl_easy_cleanup(3) on the cor‐
22 responding CURL handle.
23
25 HTTP(S)
26
28 CURL *curl = curl_easy_init();
29 if(curl) {
30 CURLcode res;
31 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
32 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
33 res = curl_easy_perform(curl);
34 if(res == CURLE_OK) {
35 char *url = NULL;
36 curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
37 if(url)
38 printf("Redirect to: %s\n", url);
39 }
40 curl_easy_cleanup(curl);
41 }
42
44 Added in 7.4
45
47 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
48 if not.
49
51 curl_easy_getinfo(3), curl_easy_setopt(3),
52
53
54
55libcurl 8.0.1 January 02, 2023 CURLINFO_EFFECTIVE_URL(3)