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

NAME

6       CURLINFO_REDIRECT_URL - get the URL a redirect would go to
7

SYNOPSIS

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

DESCRIPTION

15       Pass a pointer to a char pointer to receive the URL  a  redirect  would
16       take  you  to  if  you would enable CURLOPT_FOLLOWLOCATION(3). This can
17       come very handy if you think using the built-in libcurl redirect  logic
18       isn't  good  enough  for you but you would still prefer to avoid imple‐
19       menting all the magic of figuring out the new URL.
20
21       This URL is also set if the CURLOPT_MAXREDIRS(3) limit prevented a  re‐
22       direct to happen (since 7.54.1).
23

PROTOCOLS

25       HTTP(S)
26

EXAMPLE

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

AVAILABILITY

43       Added in 7.18.2
44

RETURN VALUE

46       Returns  CURLE_OK  if the option is supported, and CURLE_UNKNOWN_OPTION
47       if not.
48

SEE ALSO

50       curl_easy_getinfo(3), curl_easy_setopt(3),
51
52
53
54libcurl 7.66.0                   June 24, 2017        CURLINFO_REDIRECT_URL(3)
Impressum