Skip to content

Commit

Permalink
curl optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Apr 12, 2019
1 parent ff602e0 commit 5044666
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/rpcconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
RPCConnection::RPCConnection(const std::string url, const std::string userpwd) : url(url),
userpwd(userpwd)
{
curl_global_init(CURL_GLOBAL_ALL);
}

void RPCConnection::setURL(const std::string url)
Expand Down Expand Up @@ -47,16 +48,8 @@ size_t CurlWrite_CallbackFunc_StdString(void *contents, size_t size, size_t nmem
return newLength;
}

std::string RPCConnection::execute(const std::string data)
std::string RPCConnection::execute(std::string data)
{
CURLcode res = curl_global_init(CURL_GLOBAL_ALL);
if (res != 0)
{
#ifdef LOGGER_ENABLED
logWarning("Failed curl init, request failed");
#endif
}

CURL *curl = curl_easy_init();
struct curl_slist *headers = NULL;

Expand Down Expand Up @@ -86,7 +79,6 @@ std::string RPCConnection::execute(const std::string data)
}

curl_easy_cleanup(curl);
curl_global_cleanup();

free(headers);

Expand Down

0 comments on commit 5044666

Please sign in to comment.