1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#include "test.h"
#define DEBUG_OUTPUT true
rickysWrapper::rickysWrapper()
{
//ctor
curl_global_init(CURL_GLOBAL_ALL);
this->curl = curl_easy_init();
curl_easy_setopt(this->curl, CURLOPT_NOPROGRESS, 1);
curl_easy_setopt(this->curl, CURLOPT_AUTOREFERER, 1);
curl_easy_setopt(this->curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(this->curl, CURLOPT_ENCODING, "");
curl_easy_setopt(this->curl, CURLOPT_NOSIGNAL, 1);
if (DEBUG_OUTPUT)
std::cout << "Debug: class initialized" << std::endl;
}
std::string rickysWrapper::getRequest(char* url)
{
std::cout << "Started function" << std::endl;
CURLcode result;
std::cout << "Created result object" << std::endl;
curl_easy_setopt(this->curl, CURLOPT_HTTPGET, 1);
//std::cout << "Set HTTPGET" << std::endl;
curl_easy_setopt(this->curl, CURLOPT_URL, url);
std::cout << "Set url" << std::endl;
result = curl_easy_perform(this->curl);
std::cout << "processed!" << std::endl;
std::cout << curl_easy_strerror(result) << std::endl;
}
rickysWrapper::~rickysWrapper()
{
//dtor
std::cout << "destroying" << std::endl;
curl_easy_cleanup(this->curl);
curl_global_cleanup();
if (DEBUG_OUTPUT)
std::cout << "Debug: class destroyed" << std::endl;
}
|