From 15c1e154668da639b7b1766ae3f352615b7a5561 Mon Sep 17 00:00:00 2001 From: tastytea Date: Wed, 8 Jan 2020 11:53:01 +0100 Subject: [PATCH] Follow up to 10 HTTP redirects automatically. This includes permanent redirects. --- src/curl_wrapper.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/curl_wrapper.cpp b/src/curl_wrapper.cpp index 5547365..76c9a2e 100644 --- a/src/curl_wrapper.cpp +++ b/src/curl_wrapper.cpp @@ -193,6 +193,16 @@ void CURLWrapper::setup_curl() throw CURLException{code, "Failed to set User-Agent", _curl_buffer_error}; } + + // The next 2 only fail if HTTP is not supported. + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) + code = curl_easy_setopt(_connection, CURLOPT_FOLLOWLOCATION, 1L); + if (code != CURLE_OK) + { + throw CURLException{code, "HTTP is not supported.", _curl_buffer_error}; + } + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) + curl_easy_setopt(_connection, CURLOPT_MAXREDIRS, 10L); } } // namespace mastodonpp