/** @file * @brief HTTPHelper class header. This class represents a Helper to perform HTTP operations easily. * * * * @copyright Intra2net AG * @license GPLv2 */ #ifndef HTTPHELPER_H #define HTTPHELPER_H #include "logger.hpp" #include #include class HTTPHelper { private: Logger::Ptr Log; std::string Proxy; int ProxyPort; CURLcode CurlError; CURL* CurlEasyHandle; std::string CurlWritedataBuff; std::string ReceivedCurlData; char CurlErrBuff[CURL_ERROR_SIZE]; CURLcode set_curl_url(const std::string& url); CURLcode set_curl_auth(const std::string& username, const std::string& password); CURL* init_curl(std::string& curl_writedata_buff, char* curl_err_buff); public: typedef boost::shared_ptr Ptr; HTTPHelper(); HTTPHelper(Logger::Ptr _log, const std::string& _proxy, const int _proxy_port, const std::string& _username, const std::string& _password); HTTPHelper(Logger::Ptr _log, const std::string& _proxy, const int _proxy_port); ~HTTPHelper(); long http_get(const std::string& ip); std::string get_curl_data() const; bool is_initialized() const; // libcurl is a C library, so we have to make the callback member function static :-( static size_t http_receive(const char *inBuffer, size_t size, size_t nmemb, std::string *outBuffer); }; #endif