-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.h
65 lines (49 loc) · 1.22 KB
/
client.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef HTTP_CLIENT
#define HTTP_CLIENT
#include <curl/curl.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define CLIENT_ERROR "Http Client error: "
typedef struct curl_slist header_list_t;
struct HttpClientConfig
{
string client_cert_path;
string client_ca_cert_path;
};
struct HttpRequest
{
string method;
string url;
vector<string> headers;
};
struct HttpResponse
{
int response_code;
string data;
vector<string> headers;
};
typedef struct HttpClientConfig http_client_config_t;
typedef struct HttpRequest http_request_t;
typedef struct HttpResponse http_response_t;
void check_status(int);
void show_client_error(int);
void append_header(http_request_t*, string);
class HttpClient
{
CURL* curl_instance;
header_list_t* current_headers;
public:
HttpClient();
HttpClient(http_client_config_t);
void perform_setup();
void perform_operation();
void process_ssl_config(http_client_config_t);
void process_config(http_client_config_t);
void process_request(http_request_t);
void process_headers(http_request_t);
void perform_cleanup();
int make_request(http_request_t);
};
#endif