2019-01-19 12:40:10 +00:00
|
|
|
#ifndef NETWORK_HPP
|
|
|
|
#define NETWORK_HPP
|
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
|
2020-01-15 09:00:25 +00:00
|
|
|
#include <Windows.h>
|
2020-01-15 15:30:30 +00:00
|
|
|
#include <WinInet.h>
|
|
|
|
#include <string>
|
2019-02-04 16:39:48 +00:00
|
|
|
|
|
|
|
using string = std::wstring;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2019-01-19 12:40:10 +00:00
|
|
|
#include <curl/curl.h>
|
2020-01-15 09:00:25 +00:00
|
|
|
#include <string>
|
2019-01-19 12:40:10 +00:00
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
using string = std::string;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2020-01-15 15:30:30 +00:00
|
|
|
class Request {
|
2019-01-19 12:40:10 +00:00
|
|
|
public:
|
2020-01-15 21:23:11 +00:00
|
|
|
Request();
|
2020-01-15 15:30:30 +00:00
|
|
|
~Request();
|
2020-01-15 09:00:25 +00:00
|
|
|
std::string get( const string &url );
|
2020-01-15 15:30:30 +00:00
|
|
|
std::string post( const string &url, const std::string &data );
|
|
|
|
void addHeader( const string &header );
|
2020-01-15 09:00:25 +00:00
|
|
|
void clearHeader();
|
2020-01-15 15:30:30 +00:00
|
|
|
bool initSuccessful();
|
2020-01-15 21:23:11 +00:00
|
|
|
void setServer( const string &server );
|
2019-02-04 16:39:48 +00:00
|
|
|
|
2019-01-19 12:40:10 +00:00
|
|
|
private:
|
2019-02-04 16:39:48 +00:00
|
|
|
#ifdef _WIN32
|
2020-01-15 15:30:30 +00:00
|
|
|
HINTERNET _hInternet = nullptr;
|
|
|
|
HINTERNET _hConnect = nullptr;
|
|
|
|
std::wstring _headers = L"";
|
2019-02-04 16:39:48 +00:00
|
|
|
#else
|
2020-01-15 15:30:30 +00:00
|
|
|
CURL *_curl_handle = nullptr;
|
|
|
|
struct curl_slist *_chunk = nullptr;
|
2020-01-15 21:23:11 +00:00
|
|
|
string _server;
|
2019-02-04 16:39:48 +00:00
|
|
|
#endif
|
2019-01-19 12:40:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|