Bugfix: User \n as delimiter for service tzo.
[bpdyndnsd] / src / httphelper.h
CommitLineData
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
19class HTTPHelper
20{
92beaba3 21
efbde536
BS
22private:
23
b30f392d 24 Logger::Ptr Log;
efbde536
BS
25 std::string Proxy;
26 int ProxyPort;
27 CURL* CurlEasyHandle;
28 std::string CurlWritedataBuff;
3ef770e2 29 char CurlErrBuff[CURL_ERROR_SIZE];
efbde536 30
2dd2db3e 31 void set_curl_url(const std::string& url);
2dd2db3e
BS
32 void set_curl_auth(const std::string& username, const std::string& password);
33
efbde536
BS
34public:
35
36 typedef boost::shared_ptr<HTTPHelper> Ptr;
37
38 HTTPHelper();
39
2dd2db3e 40 HTTPHelper(Logger::Ptr _log, const std::string& _proxy, const int _proxy_port, const std::string& _username, const std::string& _password);
efbde536 41
7de01277
BS
42 HTTPHelper(Logger::Ptr _log, const std::string& _proxy, const int _proxy_port);
43
efbde536
BS
44 ~HTTPHelper();
45
46 CURL* init_curl(std::string& curl_writedata_buff, char* curl_err_buff) const;
47
d5a516ba 48 long http_get(const std::string& ip);
efbde536 49
b6228761
BS
50 std::string get_curl_data() const;
51
efbde536
BS
52 // libcurl is a C library, so we have to make the callback member function static :-(
53 static int http_receive(char *inBuffer, size_t size, size_t nmemb, std::string *outBuffer);
efbde536
BS
54};
55
56#endif