diff options
Diffstat (limited to 'src/utils/cpp')
-rw-r--r-- | src/utils/cpp/curl_easy_handle.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/utils/cpp/curl_easy_handle.cpp b/src/utils/cpp/curl_easy_handle.cpp index c823890d..7fac31fc 100644 --- a/src/utils/cpp/curl_easy_handle.cpp +++ b/src/utils/cpp/curl_easy_handle.cpp @@ -75,8 +75,9 @@ auto CurlEasyHandle::EasyWriteToString(gsl::owner<char*> data, #ifdef BOOTSTRAP_BUILD_TOOL return 0; #else - (static_cast<std::string*>(userptr))->append(data, size * nmemb); - return static_cast<std::streamsize>(size * nmemb); + size_t actual_size = size * nmemb; + (static_cast<std::string*>(userptr))->append(data, actual_size); + return static_cast<std::streamsize>(actual_size); #endif // BOOTSTRAP_BUILD_TOOL } @@ -91,6 +92,10 @@ auto CurlEasyHandle::DownloadToFile( // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-vararg) curl_easy_setopt(handle_.get(), CURLOPT_URL, url.c_str()); + // ensure redirects are allowed, otherwise it might simply read empty + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-vararg) + curl_easy_setopt(handle_.get(), CURLOPT_FOLLOWLOCATION, 1); + // set callback for writing to file std::ofstream file(file_path.c_str(), std::ios::binary); @@ -135,6 +140,10 @@ auto CurlEasyHandle::DownloadToString(std::string const& url) noexcept // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-vararg) curl_easy_setopt(handle_.get(), CURLOPT_URL, url.c_str()); + // ensure redirects are allowed, otherwise it might simply read empty + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-vararg) + curl_easy_setopt(handle_.get(), CURLOPT_FOLLOWLOCATION, 1); + // set callback for writing to string std::string content{}; |