1CURLINFO_EFFECTIVE_URL(3)  curl_easy_getinfo options CURLINFO_EFFECTIVE_URL(3)
2
3
4

NAME

6       CURLINFO_EFFECTIVE_URL - get the last used URL
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode  curl_easy_getinfo(CURL  *handle, CURLINFO_EFFECTIVE_URL, char
12       **urlp);
13

DESCRIPTION

15       Pass in a pointer to a char pointer and get  the  last  used  effective
16       URL.
17
18       In  cases  when  you've  asked libcurl to follow redirects, it may very
19       well not be the same value you set with CURLOPT_URL(3).
20
21       The urlp pointer will be NULL or pointing to private  memory  you  MUST
22       NOT free - it gets freed when you call curl_easy_cleanup(3) on the cor‐
23       responding CURL handle.
24

PROTOCOLS

26       HTTP(S)
27

EXAMPLE

29       CURL *curl = curl_easy_init();
30       if(curl) {
31         CURLcode res;
32         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
33         curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
34         res = curl_easy_perform(curl);
35         if(res == CURLE_OK) {
36           char *url = NULL;
37           curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
38           if(url)
39             printf("Redirect to: %s\n", url);
40         }
41         curl_easy_cleanup(curl);
42       }
43

AVAILABILITY

45       Added in 7.4
46

RETURN VALUE

48       Returns CURLE_OK if the option is supported,  and  CURLE_UNKNOWN_OPTION
49       if not.
50

SEE ALSO

52       curl_easy_getinfo(3), curl_easy_setopt(3),
53
54
55
56libcurl 7.79.1                 November 04, 2020     CURLINFO_EFFECTIVE_URL(3)
Impressum