1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLINFO_EFFECTIVE_URL 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_FOLLOWLOCATION (3) 9 - curl_easy_getinfo (3) 10 - curl_easy_setopt (3) 11Protocol: 12 - HTTP 13--- 14 15# NAME 16 17CURLINFO_EFFECTIVE_URL - get the last used URL 18 19# SYNOPSIS 20 21~~~c 22#include <curl/curl.h> 23 24CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_EFFECTIVE_URL, char **urlp); 25~~~ 26 27# DESCRIPTION 28 29Pass in a pointer to a char pointer and get the last used effective URL. 30 31In cases when you have asked libcurl to follow redirects, it may not be the same 32value you set with CURLOPT_URL(3). 33 34The **urlp** pointer is NULL or points to private memory. You MUST NOT free 35- it gets freed when you call curl_easy_cleanup(3) on the corresponding 36CURL handle. 37 38# EXAMPLE 39 40~~~c 41int main(void) 42{ 43 CURL *curl = curl_easy_init(); 44 if(curl) { 45 CURLcode res; 46 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 47 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); 48 res = curl_easy_perform(curl); 49 if(res == CURLE_OK) { 50 char *url = NULL; 51 curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url); 52 if(url) 53 printf("Redirect to: %s\n", url); 54 } 55 curl_easy_cleanup(curl); 56 } 57} 58~~~ 59 60# AVAILABILITY 61 62Added in 7.4 63 64# RETURN VALUE 65 66Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 67