Only check for libcurl return code if it could return an error.
This commit is contained in:
parent
d2de78ff9e
commit
0e3b812b54
|
@ -203,70 +203,29 @@ void CURLWrapper::setup_curl()
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
||||||
CURLcode code{curl_easy_setopt(_connection, CURLOPT_ERRORBUFFER,
|
curl_easy_setopt(_connection, CURLOPT_ERRORBUFFER, _curl_buffer_error);
|
||||||
_curl_buffer_error)};
|
|
||||||
if (code != CURLE_OK)
|
|
||||||
{
|
|
||||||
throw CURLException{code, "Failed to set error buffer."};
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
||||||
code = curl_easy_setopt(_connection, CURLOPT_WRITEFUNCTION,
|
curl_easy_setopt(_connection, CURLOPT_WRITEFUNCTION, writer_body_wrapper);
|
||||||
writer_body_wrapper);
|
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
||||||
if (code != CURLE_OK)
|
curl_easy_setopt(_connection, CURLOPT_WRITEDATA, this);
|
||||||
{
|
|
||||||
throw CURLException{code, "Failed to set write function",
|
|
||||||
_curl_buffer_error};
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
||||||
code = curl_easy_setopt(_connection, CURLOPT_WRITEDATA, this);
|
curl_easy_setopt(_connection, CURLOPT_HEADERFUNCTION,
|
||||||
if (code != CURLE_OK)
|
|
||||||
{
|
|
||||||
throw CURLException{code, "Failed to set write data",
|
|
||||||
_curl_buffer_error};
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
|
||||||
code = curl_easy_setopt(_connection, CURLOPT_HEADERFUNCTION,
|
|
||||||
writer_header_wrapper);
|
writer_header_wrapper);
|
||||||
if (code != CURLE_OK)
|
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
||||||
{
|
curl_easy_setopt(_connection, CURLOPT_HEADERDATA, this);
|
||||||
throw CURLException{code, "Failed to set header function",
|
|
||||||
_curl_buffer_error};
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
||||||
code = curl_easy_setopt(_connection, CURLOPT_HEADERDATA, this);
|
curl_easy_setopt(_connection, CURLOPT_XFERINFOFUNCTION, progress_wrapper);
|
||||||
if (code != CURLE_OK)
|
|
||||||
{
|
|
||||||
throw CURLException{code, "Failed to set header data",
|
|
||||||
_curl_buffer_error};
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
|
||||||
code = curl_easy_setopt(_connection, CURLOPT_XFERINFOFUNCTION,
|
|
||||||
progress_wrapper);
|
|
||||||
if (code != CURLE_OK)
|
|
||||||
{
|
|
||||||
throw CURLException{code, "Failed to set transfer info function",
|
|
||||||
_curl_buffer_error};
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
||||||
curl_easy_setopt(_connection, CURLOPT_XFERINFODATA, this);
|
curl_easy_setopt(_connection, CURLOPT_XFERINFODATA, this);
|
||||||
if (code != CURLE_OK)
|
|
||||||
{
|
|
||||||
throw CURLException{code, "Failed to set transfer info data",
|
|
||||||
_curl_buffer_error};
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
||||||
curl_easy_setopt(_connection, CURLOPT_NOPROGRESS, 0L);
|
curl_easy_setopt(_connection, CURLOPT_NOPROGRESS, 0L);
|
||||||
|
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
||||||
code = curl_easy_setopt(_connection, CURLOPT_USERAGENT,
|
CURLcode code{curl_easy_setopt(_connection, CURLOPT_USERAGENT,
|
||||||
(string("mastorss/") += version).c_str());
|
(string("mastorss/") += version).c_str())};
|
||||||
if (code != CURLE_OK)
|
if (code != CURLE_OK)
|
||||||
{
|
{
|
||||||
throw CURLException{code, "Failed to set User-Agent",
|
throw CURLException{code, "Failed to set User-Agent",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user