Follow up to 10 HTTP redirects automatically.

This includes permanent redirects.
This commit is contained in:
tastytea 2020-01-08 11:53:01 +01:00
parent 50ae16002b
commit 15c1e15466
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 10 additions and 0 deletions

View File

@ -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