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 | ||
23 | std::string Proxy; | |
24 | int ProxyPort; | |
25 | CURL* CurlEasyHandle; | |
26 | std::string CurlWritedataBuff; | |
27 | char* CurlErrBuff; | |
28 | ||
29 | Logger::Ptr Log; | |
30 | ||
31 | public: | |
32 | ||
33 | typedef boost::shared_ptr<HTTPHelper> Ptr; | |
34 | ||
35 | HTTPHelper(); | |
36 | ||
37 | HTTPHelper(Logger::Ptr _log, std::string _proxy, int _proxy_port); | |
38 | ||
39 | ~HTTPHelper(); | |
40 | ||
41 | CURL* init_curl(std::string& curl_writedata_buff, char* curl_err_buff) const; | |
42 | ||
43 | ||
44 | std::string http_get(const std::string& url); | |
45 | ||
46 | void set_curl_url(const std::string& url); | |
47 | ||
48 | // libcurl is a C library, so we have to make the callback member function static :-( | |
49 | static int http_receive(char *inBuffer, size_t size, size_t nmemb, std::string *outBuffer); | |
50 | ||
51 | }; | |
52 | ||
53 | #endif |