Commit | Line | Data |
---|---|---|
efbde536 BS |
1 | /** @file |
2 | * @brief HTTPHelper class header. This class represents a Helper to perform HTTP operations easily. | |
3 | * | |
4 | * | |
5 | * | |
6 | * @copyright Intra2net AG | |
7 | * @license GPLv2 | |
8 | */ | |
9 | ||
10 | #ifndef HTTPHELPER_H | |
11 | #define HTTPHELPER_H | |
12 | ||
13 | #include "logger.h" | |
14 | ||
15 | #include <boost/shared_ptr.hpp> | |
16 | #include <curl/curl.h> | |
17 | ||
18 | ||
19 | class HTTPHelper | |
20 | { | |
21 | private: | |
22 | ||
b30f392d | 23 | Logger::Ptr Log; |
efbde536 BS |
24 | std::string Proxy; |
25 | int ProxyPort; | |
26 | CURL* CurlEasyHandle; | |
27 | std::string CurlWritedataBuff; | |
28 | char* CurlErrBuff; | |
29 | ||
2dd2db3e | 30 | void set_curl_url(const std::string& url); |
2dd2db3e BS |
31 | void set_curl_auth(const std::string& username, const std::string& password); |
32 | ||
efbde536 BS |
33 | public: |
34 | ||
35 | typedef boost::shared_ptr<HTTPHelper> Ptr; | |
36 | ||
37 | HTTPHelper(); | |
38 | ||
2dd2db3e | 39 | HTTPHelper(Logger::Ptr _log, const std::string& _proxy, const int _proxy_port, const std::string& _username, const std::string& _password); |
efbde536 | 40 | |
7de01277 BS |
41 | HTTPHelper(Logger::Ptr _log, const std::string& _proxy, const int _proxy_port); |
42 | ||
efbde536 BS |
43 | ~HTTPHelper(); |
44 | ||
45 | CURL* init_curl(std::string& curl_writedata_buff, char* curl_err_buff) const; | |
46 | ||
d5a516ba | 47 | long http_get(const std::string& ip); |
efbde536 | 48 | |
b6228761 BS |
49 | std::string get_curl_data() const; |
50 | ||
efbde536 BS |
51 | // libcurl is a C library, so we have to make the callback member function static :-( |
52 | static int http_receive(char *inBuffer, size_t size, size_t nmemb, std::string *outBuffer); | |
efbde536 BS |
53 | }; |
54 | ||
55 | #endif |