Fix some warnings.
Avoid copy, initialize members in header, initialize variables.
This commit is contained in:
parent
c9211e621e
commit
f4bd5abd01
@ -245,11 +245,11 @@ protected:
|
|||||||
virtual void set_useragent(string_view useragent);
|
virtual void set_useragent(string_view useragent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CURL *_connection;
|
CURL *_connection{nullptr};
|
||||||
char _curl_buffer_error[CURL_ERROR_SIZE];
|
char _curl_buffer_error[CURL_ERROR_SIZE]{'\0'};
|
||||||
string _curl_buffer_headers;
|
string _curl_buffer_headers;
|
||||||
string _curl_buffer_body;
|
string _curl_buffer_body;
|
||||||
bool _stream_cancelled;
|
bool _stream_cancelled{false};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes curl and sets up connection.
|
* @brief Initializes curl and sets up connection.
|
||||||
@ -297,7 +297,7 @@ private:
|
|||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
*/
|
*/
|
||||||
int progress(void *clientp, curl_off_t dltotal, curl_off_t dlnow,
|
int progress(void *clientp, curl_off_t dltotal, curl_off_t dlnow,
|
||||||
curl_off_t ultotal, curl_off_t ulnow);
|
curl_off_t ultotal, curl_off_t ulnow) const;
|
||||||
|
|
||||||
//! @copydoc writer_body_wrapper
|
//! @copydoc writer_body_wrapper
|
||||||
static inline int progress_wrapper(void *f, void *clientp,
|
static inline int progress_wrapper(void *f, void *clientp,
|
||||||
|
@ -70,7 +70,7 @@ string Connection::get_new_stream_contents()
|
|||||||
{
|
{
|
||||||
_buffer_mutex.lock();
|
_buffer_mutex.lock();
|
||||||
auto &buffer{get_buffer()};
|
auto &buffer{get_buffer()};
|
||||||
const string buffer_copy{buffer};
|
string buffer_copy{buffer};
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
_buffer_mutex.unlock();
|
_buffer_mutex.unlock();
|
||||||
return buffer_copy;
|
return buffer_copy;
|
||||||
|
@ -56,17 +56,11 @@ void CURLWrapper::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CURLWrapper::CURLWrapper()
|
CURLWrapper::CURLWrapper()
|
||||||
: _connection{}
|
|
||||||
, _curl_buffer_error{}
|
|
||||||
, _stream_cancelled{false}
|
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
CURLWrapper::CURLWrapper(const CURLWrapper &)
|
CURLWrapper::CURLWrapper(const CURLWrapper &)
|
||||||
: _connection{}
|
|
||||||
, _curl_buffer_error{}
|
|
||||||
, _stream_cancelled{false}
|
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@ -90,7 +84,7 @@ answer_type CURLWrapper::make_request(const http_method &method, string uri,
|
|||||||
_curl_buffer_headers.clear();
|
_curl_buffer_headers.clear();
|
||||||
_curl_buffer_body.clear();
|
_curl_buffer_body.clear();
|
||||||
|
|
||||||
CURLcode code;
|
CURLcode code{CURLE_OK};
|
||||||
switch (method)
|
switch (method)
|
||||||
{
|
{
|
||||||
case http_method::GET:
|
case http_method::GET:
|
||||||
@ -186,7 +180,7 @@ answer_type CURLWrapper::make_request(const http_method &method, string uri,
|
|||||||
if (code == CURLE_OK
|
if (code == CURLE_OK
|
||||||
|| (code == CURLE_ABORTED_BY_CALLBACK && _stream_cancelled))
|
|| (code == CURLE_ABORTED_BY_CALLBACK && _stream_cancelled))
|
||||||
{
|
{
|
||||||
long http_status; // NOLINT(google-runtime-int)
|
long http_status{0}; // NOLINT(google-runtime-int)
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
||||||
curl_easy_getinfo(_connection, CURLINFO_RESPONSE_CODE, &http_status);
|
curl_easy_getinfo(_connection, CURLINFO_RESPONSE_CODE, &http_status);
|
||||||
answer.http_status = static_cast<uint16_t>(http_status);
|
answer.http_status = static_cast<uint16_t>(http_status);
|
||||||
@ -281,8 +275,8 @@ void CURLWrapper::set_cainfo(const string_view path)
|
|||||||
|
|
||||||
void CURLWrapper::set_useragent(const string_view useragent)
|
void CURLWrapper::set_useragent(const string_view useragent)
|
||||||
{
|
{
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
|
||||||
CURLcode code{
|
CURLcode code{
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
||||||
curl_easy_setopt(_connection, CURLOPT_USERAGENT, useragent.data())};
|
curl_easy_setopt(_connection, CURLOPT_USERAGENT, useragent.data())};
|
||||||
if (code != CURLE_OK)
|
if (code != CURLE_OK)
|
||||||
{
|
{
|
||||||
@ -319,7 +313,7 @@ size_t CURLWrapper::writer_header(char *data, size_t size, size_t nmemb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int CURLWrapper::progress(void *, curl_off_t, curl_off_t, curl_off_t,
|
int CURLWrapper::progress(void *, curl_off_t, curl_off_t, curl_off_t,
|
||||||
curl_off_t)
|
curl_off_t) const
|
||||||
{
|
{
|
||||||
if (_stream_cancelled)
|
if (_stream_cancelled)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user