-
Notifications
You must be signed in to change notification settings - Fork 0
/
Request.h
50 lines (34 loc) · 887 Bytes
/
Request.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// Created by Ondra on 9.4.2020.
//
#ifndef OCTISSIMO_REQUEST_H
#define OCTISSIMO_REQUEST_H
#include <functional>
#include "win.h"
#include <Winhttp.h>
#include <string>
#include <map>
using std::map;
using std::string;
std::wstring widestring(std::string s);
class WinHttpHandle {
HINTERNET handle;
public:
WinHttpHandle() {
handle = nullptr;
}
~WinHttpHandle() {
if (handle) WinHttpCloseHandle(handle);
}
WinHttpHandle &operator = (HINTERNET h) {handle = h;return *this;}
operator HINTERNET () const {return handle;}
operator bool () const {return handle != nullptr;}
};
class Request {
WinHttpHandle hSession;
WinHttpHandle hConnect;
public:
Request(const char *url);
void update(const char *endpoint, std::function<void(const std::string &, const std::map<string, string> &, long)> callback, string headers = "");
};
#endif //OCTISSIMO_REQUEST_H