1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLINFO_REDIRECT_COUNT 5Section: 3 6Source: libcurl 7See-also: 8 - CURLINFO_REDIRECT_URL (3) 9 - CURLOPT_FOLLOWLOCATION (3) 10 - curl_easy_getinfo (3) 11 - curl_easy_setopt (3) 12Protocol: 13 - All 14--- 15 16# NAME 17 18CURLINFO_REDIRECT_COUNT - get the number of redirects 19 20# SYNOPSIS 21 22~~~c 23#include <curl/curl.h> 24 25CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_REDIRECT_COUNT, 26 long *countp); 27~~~ 28 29# DESCRIPTION 30 31Pass a pointer to a long to receive the total number of redirections that were 32actually followed. 33 34# EXAMPLE 35 36~~~c 37int main(void) 38{ 39 CURL *curl = curl_easy_init(); 40 if(curl) { 41 CURLcode res; 42 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 43 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); 44 res = curl_easy_perform(curl); 45 if(res == CURLE_OK) { 46 long redirects; 47 curl_easy_getinfo(curl, CURLINFO_REDIRECT_COUNT, &redirects); 48 } 49 curl_easy_cleanup(curl); 50 } 51} 52~~~ 53 54# AVAILABILITY 55 56Added in 7.9.7 57 58# RETURN VALUE 59 60Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 61