Add copy constructor for CURLWrapper.
The copy constructor does the same as the constructor. A new CURL handle is used for the “copy”.
This commit is contained in:
parent
da1c2ba409
commit
fc32e8ac0a
|
@ -70,8 +70,12 @@ public:
|
||||||
*/
|
*/
|
||||||
CURLWrapper();
|
CURLWrapper();
|
||||||
|
|
||||||
//! Copy constructor
|
/*!
|
||||||
CURLWrapper(const CURLWrapper &other) = delete;
|
* @brief Copy constructor. Does the same as the Constructor.
|
||||||
|
*
|
||||||
|
* @since 0.5.2
|
||||||
|
*/
|
||||||
|
CURLWrapper(const CURLWrapper &);
|
||||||
|
|
||||||
//! Move constructor
|
//! Move constructor
|
||||||
CURLWrapper(CURLWrapper &&other) noexcept = delete;
|
CURLWrapper(CURLWrapper &&other) noexcept = delete;
|
||||||
|
@ -253,6 +257,13 @@ private:
|
||||||
string _curl_buffer_body;
|
string _curl_buffer_body;
|
||||||
bool _stream_cancelled;
|
bool _stream_cancelled;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Initializes curl and sets up connection.
|
||||||
|
*
|
||||||
|
* @since 0.5.2
|
||||||
|
*/
|
||||||
|
void init();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief libcurl write callback function.
|
* @brief libcurl write callback function.
|
||||||
*
|
*
|
||||||
|
|
|
@ -41,9 +41,7 @@ using std::uint16_t;
|
||||||
// No one will ever need more than 65535 connections. 😉
|
// No one will ever need more than 65535 connections. 😉
|
||||||
static atomic<uint16_t> curlwrapper_instances{0};
|
static atomic<uint16_t> curlwrapper_instances{0};
|
||||||
|
|
||||||
CURLWrapper::CURLWrapper()
|
void CURLWrapper::init()
|
||||||
: _curl_buffer_error{}
|
|
||||||
, _stream_cancelled{false}
|
|
||||||
{
|
{
|
||||||
if (curlwrapper_instances == 0)
|
if (curlwrapper_instances == 0)
|
||||||
{
|
{
|
||||||
|
@ -55,6 +53,23 @@ CURLWrapper::CURLWrapper()
|
||||||
_connection = curl_easy_init();
|
_connection = curl_easy_init();
|
||||||
setup_curl();
|
setup_curl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CURLWrapper::CURLWrapper()
|
||||||
|
: _connection{}
|
||||||
|
, _curl_buffer_error{}
|
||||||
|
, _stream_cancelled{false}
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
CURLWrapper::CURLWrapper(const CURLWrapper &)
|
||||||
|
: _connection{}
|
||||||
|
, _curl_buffer_error{}
|
||||||
|
, _stream_cancelled{false}
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
CURLWrapper::~CURLWrapper() noexcept
|
CURLWrapper::~CURLWrapper() noexcept
|
||||||
{
|
{
|
||||||
curl_easy_cleanup(_connection);
|
curl_easy_cleanup(_connection);
|
||||||
|
|
Loading…
Reference in New Issue