-
Notifications
You must be signed in to change notification settings - Fork 0
/
HttpTransmit.h
47 lines (38 loc) · 891 Bytes
/
HttpTransmit.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
#pragma once
#include <cstdint>
#include <string>
#include <unordered_map>
#include <vector>
class CHttpTransmit {
protected:
static std::wstring NewSessionId();
bool connected;
std::wstring transmitUrl, sessionId;
std::vector<uint8_t> sessionKey;
public:
static constexpr uint32_t AuthorizationRequired = 401;
static constexpr int SessionIdLen = 32;
class CResponse {
public:
bool success;
uint32_t statusCode;
std::vector<uint8_t> data;
__forceinline operator bool() {
return success;
}
};
CHttpTransmit(
const std::vector<uint8_t>& secretKey,
const std::wstring& connectUrl,
const std::wstring& transmitUrl
);
__forceinline operator bool() {
return connected;
}
CResponse TransmitTo(
const std::string& url,
const std::string& method,
const std::unordered_map<std::string, std::string>& headers,
const std::vector<uint8_t>& data
);
};