-
Notifications
You must be signed in to change notification settings - Fork 0
/
HTTPSClient.hpp
49 lines (35 loc) · 916 Bytes
/
HTTPSClient.hpp
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
#include "sdkconfig.h"
#ifndef HTTPSClient_HPP_
#define HTTPSClient_HPP_
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <utility>
#include <exception>
#include <functional>
#if defined(CONFIG_USE_ESP_TLS)
#include <esp_http_client.h>
#define _HTTPS_CLIENT_BUFFSIZE 1024
#else
#include <mongoose.h>
#endif
class HTTPSClient {
public:
int get(const char* _url);
int post(const char* _url, const char* _body);
HTTPSClient(const std::string &user_agent, const char* ca_pem, int timeout = 5000);
virtual ~HTTPSClient();
void set_read_cb(std::function<void (const char*, int)>read_cb) {
_read_cb = read_cb;
}
std::function<void (const char*, int)> _read_cb;
int exit_flag = 0;
int status_code = 0;
private:
std::string _user_agent;
const char* _ca_pem;
int _timeout;
};
#endif /* GUARD */